home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / util / misc / ReportPlus.lha / reportplus / source / rp.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-23  |  103.8 KB  |  2,951 lines

  1. /* $Filename:    ReportPlus/Source/rp.c
  2.  * $VER:         Report+ 5.53a
  3.  * $Description: Multipurpose utility
  4.  *
  5.  * © Copyright 1999-2002 James R. Jacobs. Freely distributable.
  6.  *        _
  7.  *       //      -=AMIGA=-
  8.  *      //
  9.  * _   //
  10.  * \\ //
  11.  *  \X/
  12.  
  13. #INCLUDES -------------------------------------------------------------- */
  14.  
  15. /* #include <assert.h> */
  16.  
  17. #include <exec/types.h>
  18. #include <exec/alerts.h>
  19. #include <exec/nodes.h>
  20. #include <exec/memory.h>
  21. #include <exec/execbase.h>
  22. #include <proto/exec.h>
  23. #include <intuition/intuition.h>
  24. #include <clib/intuition_protos.h>
  25. #include <intuition/gadgetclass.h>
  26. #include <libraries/gadtools.h>
  27. #include <clib/gadtools_protos.h>
  28. #include <libraries/iffparse.h>
  29. #include <workbench/workbench.h> /* struct DiskObject */
  30. #include <libraries/asl.h>
  31. #include <proto/asl.h>
  32. #include <dos/dos.h>
  33. #include <dos/dostags.h>
  34. #include <dos/dosextens.h>
  35. #include <proto/dos.h>
  36. #include <graphics/gfx.h>
  37. #include <graphics/displayinfo.h>
  38. #include <graphics/gels.h>
  39. #include <clib/graphics_protos.h>
  40. #include <utility/tagitem.h>
  41. #include <proto/utility.h>
  42. #include <workbench/icon.h>
  43. #include <clib/icon_protos.h>
  44. #include <clib/alib_protos.h>
  45. #include <resources/battmem.h>
  46. #include <resources/battmembitsamiga.h>
  47. #include <resources/battmembitsshared.h>
  48.  
  49. #define ALL_REACTION_CLASSES
  50. #define ALL_REACTION_MACROS
  51. #include <reaction/reaction.h>
  52. #include <clib/alib_protos.h>
  53. #include <clib/texteditor_protos.h>
  54. #include <gadgets/texteditor.h>
  55. #include <pragmas/texteditor_pragmas.h>
  56.  
  57. #define GID_0_LY1   0
  58. #define GID_0_BU1   1 // the function buttons must start from GID_O_BU1,
  59. #define GID_0_BU2   2 // and must all be consecutive.
  60. #define GID_0_BU3   3
  61. #define GID_0_BU4   4
  62. #define GID_0_BU5   5
  63. #define GID_0_BU6   6
  64. #define GID_0_BU7   7
  65. #define GID_0_BU8   8
  66. #define GID_0_BU9   9
  67. #define GID_0_BU10 10
  68. #define GID_0_BU11 11
  69. #define GID_0_BU12 12
  70. #define GID_0_ST1  13
  71. #define GIDS_0     GID_0_ST1
  72.  
  73. #define GID_A_LY1  0
  74. #define GIDS_A     GID_A_LY1
  75.  
  76. #include <ctype.h>
  77. #include <stdio.h>          /* FILE, printf() */
  78. #include <stdlib.h>         /* EXIT_SUCCESS, EXIT_FAILURE */
  79. #include <string.h>
  80. #include "rp.h"
  81. #include "boards.h"
  82.  
  83. #ifdef __STORM__
  84.    #pragma chip
  85. #endif
  86.  
  87. MODULE struct Image*  image[FUNCTIONS + 1];
  88. MODULE struct BitMap* bitmap[FUNCTIONS + 1];
  89. MODULE STRPTR         imagename[FUNCTIONS + 1] =
  90. {   "PROGDIR:images/f1.ilbm",
  91.     "PROGDIR:images/f2.ilbm",
  92.     "PROGDIR:images/f3.ilbm",
  93.     "PROGDIR:images/f4.ilbm",
  94.     "PROGDIR:images/f5.ilbm",
  95.     "PROGDIR:images/f6.ilbm",
  96.     "PROGDIR:images/f7.ilbm",
  97.     "PROGDIR:images/f8.ilbm",
  98.     "PROGDIR:images/f9.ilbm",
  99.     "PROGDIR:images/f10.ilbm",
  100.     "PROGDIR:images/f11.ilbm",
  101.     "PROGDIR:images/f12.ilbm",
  102.     "PROGDIR:images/amigan.ilbm"
  103. };
  104. MODULE STRPTR FunctionDesc[FUNCTIONS + 2] =
  105. {   // Edit
  106.     "Bug report",         // 1
  107.     "Aminet readme",      // 2
  108.     "Autodoc",            // 4
  109.     "Battery-backed RAM", // 9
  110.     "AGDB review",        // 1
  111.     // View
  112.     "Manufacturer IDs",   // 5
  113.     "IFF FORMs",          // 6
  114.     // Process
  115.     "EOLs/tabs",          // 7
  116.     "Icons",              // 12
  117.     // Report
  118.     "Path size",          // 8
  119.     "System files",       // 10
  120.     // Conduct
  121.     "ACSE test",          // 3
  122.     // (default)
  123.     TITLEBARTEXT
  124. };
  125.  
  126. #define MENUENTRIES 11
  127. MODULE struct NewMenu NewMenu[MENUENTRIES] =
  128. {   { NM_TITLE, "Project",       0 , 0,               0, 0},
  129.     {  NM_ITEM, "New",          "N", NM_ITEMDISABLED, 0, 0},
  130.     {  NM_ITEM, "Open...",      "O", NM_ITEMDISABLED, 0, 0},
  131.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  132.     {  NM_ITEM, "Save",         "S", NM_ITEMDISABLED, 0, 0},
  133.     {  NM_ITEM, "Save As...",   "A", NM_ITEMDISABLED, 0, 0},
  134.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  135.     {  NM_ITEM, "Quit Report+", "Q", 0,               0, 0},
  136.     { NM_TITLE, "Help",          0 , 0,               0, 0},
  137.     {  NM_ITEM, "About...",     "?", 0,               0, 0},
  138.     {   NM_END, NULL,            0 , 0,               0, 0}
  139. };
  140.  
  141. MODULE void clearkybd(void);
  142. MODULE void menu(void);
  143. MODULE void parsewb(void);
  144. MODULE void eachwildcard(STRPTR subpattern, ABOOL gui);
  145. MODULE void menu_loop(ULONG gid);
  146. MODULE void AddPathnameToTail(struct List* ListPtr, STRPTR name);
  147. MODULE void clearpathlist(struct List* ListPtr);
  148. MODULE void FreePathnameNodes(struct List* ListPtr);
  149. MODULE void sender_loop(ULONG gid);
  150. MODULE void about_loop(void);
  151.  
  152. int CXBRK(void) { return(0); }    /* Disable SAS/C Ctrl-C handling */
  153. int chkabort(void) { return(0); } /* really */
  154.  
  155. MODULE  struct Window*           AboutWindowPtr  = NULL;
  156. AGLOBAL struct Library          *WindowBase      = NULL,
  157.                                 *LayoutBase      = NULL,
  158.                                 *ButtonBase      = NULL,
  159.                                 *TextEditorBase  = NULL,
  160.                                 *LabelBase       = NULL,
  161.                                 *ListBrowserBase = NULL,
  162.                                 *ChooserBase     = NULL,
  163.                                 *StringBase      = NULL,
  164.                                 *CheckBoxBase    = NULL,
  165.                                 *BoardsBase      = NULL,
  166.                                 *BitMapBase      = NULL,
  167.                                 *FuelGaugeBase   = NULL,
  168.                                 *IntegerBase     = NULL,
  169.                                 *RadioButtonBase = NULL,
  170.                                 *SpaceBase       = NULL;
  171. AGLOBAL TEXT                    asldir[PATHNAMEFIELD + 1],
  172.                                 aslresult[PATHNAMEFIELD + 1],
  173.                                 IOBuffer[LONGESTFIELD + 1],
  174.                                 globalname[PATHNAMEFIELD + 1],
  175.                                 string[LONGESTFIELD + 1],
  176.                                 weekdaystring[LEN_DATSTRING],
  177.                                 datestring[LEN_DATSTRING],
  178.                                 timestring[LEN_DATSTRING],
  179.                                 cpuline[VLONGFIELD + 1];
  180. AGLOBAL WORD                    xsize;
  181. AGLOBAL SBYTE                   page             = 0,
  182.                                 closer           = 0;
  183. AGLOBAL ULONG                   increment,
  184.                                 offset,
  185.                                 wbval,
  186.                                 aboutsignal,
  187.                                 signal;
  188. AGLOBAL ABOOL                   BattBuffer[96],
  189.                                 done             = FALSE,
  190.                                 ram              = FALSE,
  191.                                 stop             = FALSE;
  192. AGLOBAL struct Library*         IconBase         = NULL;
  193. AGLOBAL struct Menu*            MenuPtr          = NULL;
  194. AGLOBAL struct Screen*          ScreenPtr        = NULL;
  195. AGLOBAL struct Window*          MainWindowPtr    = NULL;
  196. AGLOBAL struct TextFont*        FontPtr          = NULL;
  197. AGLOBAL struct VisualInfo*      VisualInfoPtr    = NULL;
  198. AGLOBAL struct ExAllData*       EADataPtr        = NULL;
  199. AGLOBAL struct List             EmptyList,
  200.                                 FileList;
  201. AGLOBAL struct SharedStruct shared =
  202. {   0,
  203.     "", ""
  204. };
  205.  
  206. IMPORT struct ExecBase*     SysBase;
  207. // from f1.c
  208. IMPORT struct ReportStruct  report;
  209. // from f2.c
  210. IMPORT struct AminetStruct  aminet;
  211. // from f4.c
  212. IMPORT struct AutodocStruct autodoc;
  213. // from f6.c
  214. IMPORT struct IFFStruct     iff;
  215. // from f7.c
  216. IMPORT struct Gadget*       eol_gadgets[GIDS_7 + 1];
  217. // from f9.c
  218. IMPORT struct Library*      BattMemBase;
  219. // from f11.c
  220. IMPORT struct AGDBStruct    agdb;
  221. // from f12.c
  222. IMPORT struct IconStruct    icon;
  223. IMPORT struct Gadget*       icon_gadgets[GIDS_12 + 1];
  224. IMPORT ABOOL                quit;
  225.  
  226. AGLOBAL       Object*          WinObject[FUNCTIONS + 1]; // note that WindowObject is a reserved macro
  227. AGLOBAL struct TextAttr        Topaz8 =
  228. {    (STRPTR) "topaz.font", 8, FS_NORMAL, FPF_ROMFONT | FPF_DESIGNED
  229. }; // "topaz.font" is case-sensitive
  230.  
  231. MODULE BPTR                    NilHandle         = NULL;
  232. MODULE TEXT                    pubscreen[256 + 1];
  233. MODULE ABOOL                   logo              = TRUE;
  234. MODULE        Object*          AboutWinObject    = NULL;
  235. MODULE struct Gadget          *gadgets[GIDS_0 + 1],
  236.                               *sender_gadgets[GIDS_S + 1];
  237. MODULE struct RDArgs*          ArgsPtr           = NULL;
  238. MODULE struct WBArg*           WBArg             = NULL;
  239. MODULE struct WBStartup*       WBMsg             = NULL;
  240. MODULE struct ASLBase*         ASLBase           = NULL;
  241. MODULE struct GadToolsBase*    GadToolsBase      = NULL;
  242. MODULE struct IFFParseBase*    IFFParseBase      = NULL;
  243. MODULE struct IntuitionBase*   IntuitionBase     = NULL;
  244. MODULE struct Library*         VersionBase       = NULL;
  245. MODULE struct EasyStruct       EasyStruct =
  246. {   sizeof(struct EasyStruct),
  247.     0,
  248.     "Report+: Error",
  249.     NULL,
  250.     "Quit"
  251. };
  252.  
  253. /* FUNCTIONS -------------------------------------------------------------- */
  254.  
  255. int main(int argc, char** argv)
  256. {   UWORD  i;
  257.     SLONG  args[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  258.     SLONG  number = 0, hostid = 7;
  259.     BPTR   ConfigHandle = NULL,
  260.            OldDir;
  261.  
  262.     /* Start of program.
  263.  
  264.     version embedding into executable */
  265.  
  266.     if (0) /* that is, never */
  267.         Printf("$VER: Report+ 5.53a (23.8.2002)"); /* always d.m.y format */
  268.  
  269.     for (i = 0; i <= FUNCTIONS; i++)
  270.     {   WinObject[i] = NULL;
  271.     }
  272.  
  273.     /* Check for OS3.9+... */
  274.     if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 40L)))
  275.     {   Printf("Report+: Need AmigaOS 3.9+!\n");
  276.         cleanexit(EXIT_FAILURE);
  277.     }
  278.     if (SysBase->LibNode.lib_Version < 40L)
  279.     {   Printf("Report+: Need AmigaOS 3.9+!\n");
  280.         cleanexit(EXIT_FAILURE);
  281.     }
  282.  
  283.     if (!(VersionBase = (struct Library *) OpenLibrary("version.library", 0L)))
  284.         rq("Can't open version.library!");
  285.     wbval = VersionBase->lib_Version;
  286.     CloseLibrary((struct Library *) VersionBase);
  287.     VersionBase = NULL;
  288.     if (wbval < 45)
  289.     {   Printf("Report+: Need AmigaOS 3.9+!\n");
  290.         cleanexit(EXIT_FAILURE);
  291.     }
  292.  
  293.     if (!(GadToolsBase = (struct ASLBase *) OpenLibrary("gadtools.library", 38L)))
  294.         rq("Can't open GadTools.library V38+!");
  295.     if (!(ASLBase = (struct ASLBase *) OpenLibrary("asl.library", 0L)))
  296.         rq("Can't open ASL.library!");
  297.     if (!(IFFParseBase = (struct IFFParseBase *) OpenLibrary("iffparse.library", 0L)))
  298.         rq("Can't open IFFParse.library!");
  299.     // it would be better to disable only the IFF viewer rather than abort
  300.     // the entire program.
  301.     if (!(FontPtr = OpenFont(&Topaz8)))
  302.     {   rq("Can't open Topaz 8 font!");
  303.     }
  304.  
  305.     if (!(ButtonBase      = OpenLibrary("gadgets/button.gadget", 44)))
  306.                        rq("OpenLibrary(\"gadgets/button.gadget\") failed!");
  307.     if (!(CheckBoxBase    = OpenLibrary("gadgets/checkbox.gadget", 44)))
  308.                        rq("OpenLibrary(\"gadgets/checkbox.gadget\") failed!");
  309.     if (!(ChooserBase     = OpenLibrary("gadgets/chooser.gadget", 44)))
  310.                        rq("OpenLibrary(\"gadgets/chooser.gadget\") failed!");
  311.     if (!(LabelBase       = OpenLibrary("images/label.image", 44)))
  312.                        rq("OpenLibrary(\"images/label.image\") failed!");
  313.     if (!(LayoutBase      = OpenLibrary("gadgets/layout.gadget", 44)))
  314.                        rq("OpenLibrary(\"gadgets/layout.gadget\") failed!");
  315.     if (!(ListBrowserBase = OpenLibrary("gadgets/listbrowser.gadget", 0)))
  316.                        rq("OpenLibrary(\"gadgets/listbrowser.gadget\") failed!");
  317.     if (!(StringBase      = OpenLibrary("gadgets/string.gadget", 44)))
  318.                        rq("OpenLibrary(\"gadgets/string.gadget\") failed!");
  319.     if (!(TextEditorBase  = OpenLibrary("gadgets/texteditor.gadget", 0)))
  320.                        rq("OpenLibrary(\"gadgets/texteditor.gadget\") failed!");
  321.     if (!(WindowBase      = OpenLibrary("window.class", 44)))
  322.                        rq("OpenLibrary(\"window.class\") failed!");
  323.     if (!(BitMapBase      = OpenLibrary("images/bitmap.image", 44)))
  324.                        rq("OpenLibrary(\"images/bitmap.image\") failed!");
  325.     if (!(FuelGaugeBase   = OpenLibrary("gadgets/fuelgauge.gadget", 0)))
  326.                        rq("OpenLibrary(\"gadgets/fuelgauge.gadget\") failed!");
  327.     if (!(IntegerBase     = OpenLibrary("gadgets/integer.gadget", 44)))
  328.                        rq("OpenLibrary(\"gadgets/integer.gadget\") failed!");
  329.     if (!(RadioButtonBase = OpenLibrary("gadgets/radiobutton.gadget", 45)))
  330.                        rq("OpenLibrary(\"gadgets/radiobutton.gadget\") (V45) failed!");
  331.     if (!(SpaceBase       = OpenLibrary("gadgets/space.gadget", 44)))
  332.                        rq("OpenLibrary(\"gadgets/space.gadget\") (V44) failed!");
  333.     if (!(IconBase        = OpenLibrary("icon.library", 44)))
  334.                        rq("Need icon.library V44+!");
  335.           BoardsBase      = OpenLibrary("boards.library", 0);
  336.  
  337.     pubscreen[0] = 0;
  338.     NewList(&EmptyList);
  339.     NewList(&FileList);
  340.     for (i = 0; i <= FUNCTIONS; i++)
  341.     {   image[i]  =
  342.         bitmap[i] = NULL;
  343.     }
  344.     if (!(EADataPtr = AllocVec(4096, MEMF_CLEAR | MEMF_PUBLIC)))
  345.     {   rq("Out of memory!");
  346.     }
  347.  
  348.     /* This is done for speed. Even though the Version command *might* be
  349.     resident, or *might* fit entirely into the disk buffers, we shouldn't
  350.     count on this being the case. So we copy the Version command into RAM:. */
  351.  
  352.     NilHandle = Open("NIL:", MODE_NEWFILE);
  353.     if (NilHandle)
  354.     {   if (!SystemTags("C:Copy C:Version RAM: >NIL:", SYS_Output, NilHandle, TAG_DONE))
  355.         {   ram = TRUE;
  356.         }
  357.         if (!SystemTags("C:CPU >T:ReportPlus.temp", SYS_Output, NilHandle, TAG_DONE))
  358.         {   readordie("T:ReportPlus.temp");
  359.             DeleteFile("T:ReportPlus.temp"); /* returns FALSE for failure */
  360.  
  361.             for (i = 0; i <= VLONGFIELD; i++)
  362.             {   if (IOBuffer[i] == LF)
  363.                 {   IOBuffer[i] = 0;
  364.                     break;
  365.             }   }
  366.             strcpy(cpuline, IOBuffer);
  367.         } else
  368.         {   strcpy(cpuline, "?");
  369.         }
  370.         Close(NilHandle);
  371.         NilHandle = NULL;
  372.     } else
  373.     {   strcpy(cpuline, "?");
  374.     }
  375.  
  376.     report_init();     // f1  list init, var init
  377.     aminet_init();     // f2  list init: memory loss?
  378.     newautodoc(FALSE); // f4  var init
  379.     iff_init();        // f6  var init
  380.     size_init();       // f8  list init
  381.     files_init();     // f10  pen init, list init
  382.     newagdb(FALSE);   // f11  var init
  383.     /* those must be done before we handle CLI arguments */
  384.  
  385.     if (argc) /* started from CLI */
  386.     {   if (!(ArgsPtr = ReadArgs
  387.         (   "PUBSCREEN/K,-N=NOLOGO/S,FUNCTION/N,-I=ICONTYPE/K,"
  388.             "RESET/S,TIMEOUT/S,LUNS/S,SYNC_XFER/S,SLOW_SYNC/S,TAG_QUEUES/S,HOST_ID/K/N,"
  389.             "FILE/F",
  390.             (LONG *) args,
  391.             NULL
  392.     )))
  393.         {   Printf
  394.             (   "Usage: %s [PUBSCREEN <screen>] [-n|NOLOGO] "
  395.                 "[[FUNCTION] <function>] "
  396.                 "[-i|ICONTYPE DISK|DRAWER|TOOL|PROJECT|TRASHCAN|DEVICE|KICKSTART|APPICON] "
  397.                 "[RESET [TIMEOUT] [LUNS] [SYNC_XFER] [SLOW_SYNC] [TAG_QUEUES] [HOST_ID <host_id>]] "
  398.                 "[[FILE] <file(s)...>]]\n",
  399.                 argv[0]
  400.             );
  401.             cleanexit(EXIT_FAILURE);
  402.     }
  403.         if (args[0])
  404.         {   strcpy(pubscreen, (STRPTR) args[0]);
  405.         }
  406.         if (args[1])
  407.         {   logo = FALSE;
  408.         }
  409.         if (args[2])
  410.         {   number = (SLONG) (*((SLONG *) args[2]));
  411.             if (number >= 1 && number <= FUNCTIONS)
  412.             {   page = closer = (number * 10) + 1;
  413.                 shared.function = number;
  414.             } else
  415.             {   Printf("Report+: <function> must be 1-%ld!\n", FUNCTIONS);
  416.                 cleanexit(EXIT_FAILURE);
  417.         }   }
  418.         if (args[3])
  419.         {   if (number != 12)
  420.             {   Printf("%s: <function> must be 12 for this!\n", argv[0]);
  421.                 cleanexit(EXIT_FAILURE);
  422.             }
  423.             if (!stricmp((STRPTR) args[3], "DISK"))
  424.             {   icon.type = WBDISK;
  425.             } elif (!stricmp((STRPTR) args[3], "DRAWER"))
  426.             {   icon.type = WBDRAWER;
  427.             } elif (!stricmp((STRPTR) args[3], "TOOL"))
  428.             {   icon.type = WBTOOL;
  429.             } elif (!stricmp((STRPTR) args[3], "PROJECT"))
  430.             {   icon.type = WBPROJECT;
  431.             } elif (!stricmp((STRPTR) args[3], "TRASHCAN"))
  432.             {   icon.type = WBGARBAGE;
  433.             } elif (!stricmp((STRPTR) args[3], "DEVICE"))
  434.             {   icon.type = WBDEVICE;
  435.             } elif (!stricmp((STRPTR) args[3], "KICKSTART"))
  436.             {   icon.type = WBKICK;
  437.             } elif (!stricmp((STRPTR) args[3], "APPICON"))
  438.             {   icon.type = WBAPPICON;
  439.             } else
  440.             {   Printf("%s: <icontype> must be DISK, DRAWER, TOOL, PROJECT, TRASHCAN, DEVICE, KICKSTART or APPICON!\n", argv[0]);
  441.                 cleanexit(EXIT_FAILURE);
  442.         }   }
  443.         if (args[4] || args[5] || args[6] || args[7] || args[8] || args[9] || args[10])
  444.         {   if (number != 9)
  445.             {   Printf("%s: <function> must be 9 for this!\n", argv[0]);
  446.                 cleanexit(EXIT_FAILURE);
  447.             }
  448.             if (!args[4])
  449.             {   Printf("%s: You need the RESET switch for this!\n", argv[0]);
  450.                 cleanexit(EXIT_FAILURE);
  451.             }
  452.             for (i = 0; i <= 95; i++)
  453.             {   BattBuffer[i] = FALSE;
  454.             }
  455.             BattBuffer[BATTMEM_AMIGA_AMNESIA_ADDR]          =
  456.             BattBuffer[BATTMEM_SHARED_AMNESIA_ADDR]         = TRUE; // these bits are inverted
  457.             if (args[5])
  458.             {   BattBuffer[BATTMEM_SCSI_TIMEOUT_ADDR]       = TRUE;
  459.             } else BattBuffer[BATTMEM_SCSI_TIMEOUT_ADDR]    = FALSE;
  460.             if (args[6])
  461.             {   BattBuffer[BATTMEM_SCSI_LUNS_ADDR]          = TRUE;
  462.             } else BattBuffer[BATTMEM_SCSI_LUNS_ADDR]       = FALSE;
  463.             if (args[7])
  464.             {   BattBuffer[BATTMEM_SCSI_SYNC_XFER_ADDR]     = TRUE;
  465.             } else BattBuffer[BATTMEM_SCSI_SYNC_XFER_ADDR]  = FALSE;
  466.             if (args[8])
  467.             {   BattBuffer[BATTMEM_SCSI_FAST_SYNC_ADDR]     = TRUE;
  468.             } else BattBuffer[BATTMEM_SCSI_FAST_SYNC_ADDR]  = FALSE;
  469.             if (args[9])
  470.             {   BattBuffer[BATTMEM_SCSI_TAG_QUEUES_ADDR]    = TRUE;
  471.             } else BattBuffer[BATTMEM_SCSI_TAG_QUEUES_ADDR] = FALSE;
  472.             if (args[10]) // these bits are inverted
  473.             {   hostid = (SLONG) (*((SLONG *) args[10]));
  474.                 if (hostid < 0 || hostid > 7)
  475.                 {   Printf("%s: <host_id> must be 0-7!\n", argv[0]);
  476.                     cleanexit(EXIT_FAILURE);
  477.                 }
  478.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR]     = (hostid & 4)? 0 : 1;
  479.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR + 1] = (hostid & 2)? 0 : 1;
  480.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR + 2] = (hostid & 1)? 0 : 1;
  481.             }
  482.             if (!BattMemBase)
  483.             {   if (!(BattMemBase = OpenResource(BATTMEMNAME)))
  484.                 {   rq("Can't open battery RAM resource!");
  485.             }   }
  486.             writebatt(FALSE);
  487.             Printf("Done.\n");
  488.             cleanexit(EXIT_SUCCESS);
  489.         }
  490.         if (args[11])
  491.         {   switch(number)
  492.             {
  493.             case 1:
  494.                 strcpy(report.output, (STRPTR) args[11]);
  495.                 loadreport();
  496.             break;
  497.             case 2:
  498.                 strcpy(aminet.output, (STRPTR) args[11]);
  499.                 loadaminet();
  500.             break;
  501.             case 4:
  502.                 strcpy(autodoc.output, (STRPTR) args[11]);
  503.                 loadautodoc();
  504.             break;
  505.             case 6:
  506.                 strcpy(iff.pathname, (STRPTR) args[11]);
  507.             break;
  508.             case 7:
  509.                 strcpy(shared.pathname, (STRPTR) args[11]);
  510.                 convert(FALSE);
  511.                 Printf("All done.\n");
  512.                 cleanexit(EXIT_SUCCESS);
  513.             break;
  514.             case 11:
  515.                 strcpy(  agdb.output, (STRPTR) args[11]);
  516.                 loadagdb();
  517.             break;
  518.             case 12:
  519.                 // strcpy(icon.pathname, (STRPTR) args[11]); // no need for this
  520.                 strcpy(shared.pathname, (STRPTR) args[11]);
  521.                 convert(FALSE);
  522.                 Printf("All done.\n");
  523.                 cleanexit(EXIT_SUCCESS);
  524.             break;
  525.             default:
  526.                 Printf("Report+: <function> must be 1, 2, 6, 7, 11 or 12 for this!\n");
  527.                 cleanexit(EXIT_FAILURE);
  528.             break;
  529.     }   }   }
  530.     else /* started from WB */
  531.     {   WBMsg = (struct WBStartup *) argv;
  532.         WBArg = WBMsg->sm_ArgList; /* head of the arg list */
  533.         for (i = 0; i < WBMsg->sm_NumArgs; i++, WBArg++)
  534.         {   if (WBArg->wa_Lock)
  535.             {   /* something that does not support locks */
  536.                 parsewb();
  537.             } else
  538.             {   /* lock supported; change to the proper directory */
  539.                 OldDir = CurrentDir(WBArg->wa_Lock);
  540.                 parsewb();
  541.                 CurrentDir(OldDir);
  542.             }
  543.             if (i == 1)
  544.             {   ; /* we were started from a project icon, which is
  545.                 currently unsupported */
  546.     }   }   }
  547.  
  548.     strcpy(asldir, "PROGDIR:");
  549.     /* RKM Libraries, p. 59-61: */
  550.     lockscreen();
  551.     if (GetVPModeID(&(ScreenPtr->ViewPort)) == INVALID_ID)
  552.     {   rq("Invalid default public screen mode ID!");
  553.     }
  554.     xsize   = ScreenPtr->Width;
  555.     if (!(VisualInfoPtr = (struct VisualInfo *) GetVisualInfo(ScreenPtr, TAG_DONE)))
  556.     {   rq("Can't get GadTools visual info!");
  557.     }
  558.     unlockscreen();
  559.  
  560.     if (!(MenuPtr = (struct Menu *) CreateMenus(NewMenu, TAG_DONE)))
  561.     {   rq("Can't create menus!");
  562.     }
  563.     if (!(LayoutMenus(MenuPtr, VisualInfoPtr, GTMN_NewLookMenus, TRUE, TAG_DONE)))
  564.     {   rq("Can't lay out menus!");
  565.     }
  566.  
  567.     if (ConfigHandle = (BPTR) Open("PROGDIR:ReportPlus.config", MODE_OLDFILE))
  568.     {   if (Read(ConfigHandle, IOBuffer, 24) != -1)
  569.         {   manuf_config(); //                                         20
  570.             iff_config();   //                                       19
  571.             eol_config();   //   0102030405
  572.             size_config();  // 00          06                            2122
  573.             files_config(); //               0708091011121314                23
  574.             icon_config();  //                                 161718
  575.             // spare                                         15
  576.         }
  577.         Close(ConfigHandle);
  578.         ConfigHandle = NULL;
  579.     }
  580.  
  581.     while(1)
  582.     {   if (page != 1)
  583.         {   shared.function = page / 10;
  584.         }
  585.         if (page == 1)
  586.             sender();
  587.         elif (page == 11)
  588.             report1();
  589.         elif (page == 12)
  590.             report2();
  591.         elif (page == 21)
  592.             aminet1();
  593.         elif (page == 31)
  594.             acse1();
  595.         elif (page == 32)
  596.             acse2();
  597.         elif (page == 41)
  598.             autodoc1();
  599.         elif (page == 42)
  600.             autodoc2();
  601.         elif (page == 51)
  602.             manuf1();
  603.         elif (page == 61)
  604.             iff1();
  605.         elif (page == 71)
  606.             eol1();
  607.         elif (page == 81)
  608.             size1();
  609.         elif (page == 91)
  610.             batt1();
  611.         elif (page == 101)
  612.             files1();
  613.         elif (page == 111)
  614.             agdb1();
  615.         elif (page == 121)
  616.         {   icon1();
  617.         } else
  618.         {   /* assert(page == 0); */
  619.             menu();
  620. }   }   }
  621.  
  622. MODULE void menu(void)
  623. {   PERSIST ABOOL       first = TRUE;
  624.     AUTO    struct Hook Hook0Struct;
  625.     AUTO    ULONG       i, tag[2];
  626.     AUTO    LONG        bgpen;
  627.  
  628.     /* Each of these calls to NewObject() loses 32 bytes, for a loss of
  629.        388 bytes. */
  630.  
  631.     if (first)
  632.     {   lockscreen();
  633.         for (i = 0; i < FUNCTIONS; i++)
  634.         {   if (!(image[i] = NewObject
  635.             (   BITMAP_GetClass(), NULL,
  636.                 BITMAP_SourceFile, imagename[i],
  637.                 BITMAP_Width,      35,
  638.                 BITMAP_Height,     32,
  639.                 BITMAP_Screen,     ScreenPtr,
  640.             TAG_END)
  641.             ))
  642.             {   rq("Can't create ReAction image(s)!");
  643.             }
  644.             GetAttr(BITMAP_BitMap, image[i], (ULONG *) &bitmap[i]);
  645.         }
  646.         unlockscreen();
  647.         first = FALSE;
  648.     }
  649.  
  650.     /* PAGE 0 ************************************************************* */
  651.  
  652.     InitHook(&Hook0Struct, Hook0Func, NULL);
  653.  
  654.     lockscreen();
  655.  
  656.     bgpen = FindColor
  657.     (   ScreenPtr->ViewPort.ColorMap,
  658.         0x96969696,
  659.         0x96969696,
  660.         0x96969696,
  661.         -1
  662.     );
  663.  
  664.     if (logo)
  665.     {   tag[0] = LAYOUT_AddImage;
  666.         tag[1] = NewObject
  667.         (   BITMAP_GetClass(), NULL,
  668.             // bitmap tags
  669.             BITMAP_SourceFile, "PROGDIR:images/logo.ilbm",
  670.             BITMAP_Masking,    TRUE,
  671.             BITMAP_Screen,     ScreenPtr,
  672.             TAG_DONE
  673.         );
  674.     } else
  675.     {   tag[0] = TAG_IGNORE;
  676.         tag[1] = NULL;
  677.     }
  678.  
  679.     if (!(WinObject[0] = NewObject(WINDOW_GetClass(), NULL,
  680.         // window tags
  681.         WA_PubScreen,             ScreenPtr,
  682.         WA_ScreenTitle,           TITLEBARTEXT,
  683.         WA_Title,                 "Report+: Main Menu",
  684.         WA_Activate,              TRUE,
  685.         WA_DepthGadget,           TRUE,
  686.         WA_DragBar,               TRUE,
  687.         WA_CloseGadget,           TRUE,
  688.         WA_IDCMP,                 IDCMP_RAWKEY | IDCMP_INTUITICKS,
  689.         WINDOW_IDCMPHook,         &Hook0Struct,
  690.         WINDOW_IDCMPHookBits,     IDCMP_RAWKEY | IDCMP_INTUITICKS,
  691.         WINDOW_MenuStrip,         MenuPtr,
  692.         WINDOW_Position,          WPOS_CENTERSCREEN,
  693.         WINDOW_ParentGroup,       gadgets[GID_0_LY1] =
  694.         NewObject
  695.         (   LAYOUT_GetClass(),         NULL,
  696.             // root-layout tags
  697.             LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  698.             LAYOUT_SpaceOuter,         TRUE,
  699.             LAYOUT_DeferLayout,        TRUE,
  700.             LAYOUT_AddChild,
  701.             NewObject
  702.             (   LAYOUT_GetClass(),     NULL,
  703.                 // layout tags
  704.                 LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  705.                 LAYOUT_SpaceOuter,     TRUE,
  706.                 LAYOUT_DeferLayout,    TRUE,
  707.                 LAYOUT_HorizAlignment, LALIGN_CENTER,
  708.                 tag[0],                tag[1],
  709.                 TAG_DONE
  710.             ),
  711.             LAYOUT_AddChild,
  712.             NewObject
  713.             (   LAYOUT_GetClass(), NULL,
  714.                 // layout tags
  715.                 LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  716.                 LAYOUT_SpaceOuter,     TRUE,
  717.                 LAYOUT_DeferLayout,    TRUE,
  718.                 LAYOUT_HorizAlignment, LALIGN_CENTER,
  719.                 LAYOUT_AddImage,
  720.                 NewObject
  721.                 (   LABEL_GetClass(),    NULL,
  722.                     // label tags
  723.                     LABEL_Justification, LJ_CENTRE,
  724.                     LABEL_Text,          "Edit:",
  725.                     TAG_END
  726.                 ),
  727.                 TAG_END
  728.             ),
  729.             CHILD_WeightedHeight,      0,
  730.             LAYOUT_AddChild,
  731.             NewObject
  732.             (   LAYOUT_GetClass(),         NULL,
  733.                 // layout tags
  734.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  735.                 LAYOUT_SpaceOuter,         TRUE,
  736.                 LAYOUT_DeferLayout,        TRUE,
  737.                 LAYOUT_AddChild,           gadgets[GID_0_BU1] =
  738.                 NewObject
  739.                 (   NULL, "button.gadget",
  740.                     // button tags
  741.                     GA_ID,                 GID_0_BU1,
  742.                     GA_Left,               20,
  743.                     GA_Top,                20,
  744.                     GA_Width,              41,
  745.                     GA_Height,             40,
  746.                     GA_RelVerify,          TRUE,
  747.                     GA_Image,
  748.                     NewObject
  749.                     (   BITMAP_GetClass(),   NULL,
  750.                         // bitmap tags
  751.                         BITMAP_BitMap,       bitmap[1 - 1],
  752.                         BITMAP_Width,        35,
  753.                         BITMAP_Height,       32,
  754.                         TAG_DONE
  755.                     ),
  756.                     BUTTON_BackgroundPen,    bgpen,
  757.                     BUTTON_FillPen,          bgpen,
  758.                     TAG_DONE
  759.                 ),
  760.                 LAYOUT_AddChild,           gadgets[GID_0_BU2] =
  761.                 NewObject
  762.                 (   NULL, "button.gadget",
  763.                     // button tags
  764.                     GA_ID,                 GID_0_BU2,
  765.                     GA_Left,               20,
  766.                     GA_Top,                20,
  767.                     GA_Width,              41,
  768.                     GA_Height,             40,
  769.                     GA_RelVerify,          TRUE,
  770.                     GA_Image,
  771.                     NewObject
  772.                     (   BITMAP_GetClass(),   NULL,
  773.                         // bitmap tags
  774.                         BITMAP_BitMap,       bitmap[2 - 1],
  775.                         BITMAP_Width,        35,
  776.                         BITMAP_Height,       32,
  777.                         TAG_DONE
  778.                     ),
  779.                     BUTTON_BackgroundPen,    bgpen,
  780.                     BUTTON_FillPen,          bgpen,
  781.                     TAG_DONE
  782.                 ),
  783.                 LAYOUT_AddChild,           gadgets[GID_0_BU3] =
  784.                 NewObject
  785.                 (   NULL, "button.gadget",
  786.                     // button tags
  787.                     GA_ID,                 GID_0_BU3,
  788.                     GA_Left,               20,
  789.                     GA_Top,                20,
  790.                     GA_Width,              41,
  791.                     GA_Height,             40,
  792.                     GA_RelVerify,          TRUE,
  793.                     GA_Image,              NewObject
  794.                     (   BITMAP_GetClass(),   NULL,
  795.                         // bitmap tags
  796.                         BITMAP_BitMap,       bitmap[4 - 1],
  797.                         BITMAP_Width,        35,
  798.                         BITMAP_Height,       32,
  799.                         TAG_DONE
  800.                     ),
  801.                     BUTTON_BackgroundPen,    bgpen,
  802.                     BUTTON_FillPen,          bgpen,
  803.                     TAG_DONE
  804.                 ),
  805.                 LAYOUT_AddChild,           gadgets[GID_0_BU4] = NewObject
  806.                 (   NULL, "button.gadget",
  807.                     // button tags
  808.                     GA_ID,                 GID_0_BU4,
  809.                     GA_Left,               20,
  810.                     GA_Top,                20,
  811.                     GA_Width,              41,
  812.                     GA_Height,             40,
  813.                     GA_RelVerify,          TRUE,
  814.                     GA_Image,              NewObject
  815.                     (   BITMAP_GetClass(),   NULL,
  816.                         // bitmap tags
  817.                         BITMAP_BitMap,       bitmap[9 - 1],
  818.                         BITMAP_Width,        35,
  819.                         BITMAP_Height,       32,
  820.                         TAG_DONE
  821.                     ),
  822.                     BUTTON_BackgroundPen,    bgpen,
  823.                     BUTTON_FillPen,          bgpen,
  824.                     TAG_DONE
  825.                 ),
  826.                 LAYOUT_AddChild,           gadgets[GID_0_BU5] = (struct Gadget *) NewObject
  827.                 (   NULL, "button.gadget",
  828.                     // button tags
  829.                     GA_ID,                 GID_0_BU5,
  830.                     GA_Left,               20,
  831.                     GA_Top,                20,
  832.                     GA_Width,              41,
  833.                     GA_Height,             40,
  834.                     GA_RelVerify,          TRUE,
  835.                     GA_Image,              NewObject
  836.                     (   BITMAP_GetClass(),   NULL,
  837.                         // bitmap tags
  838.                         BITMAP_BitMap,       bitmap[11 - 1],
  839.                         BITMAP_Width,        35,
  840.                         BITMAP_Height,       32,
  841.                         TAG_DONE
  842.                     ),
  843.                     BUTTON_BackgroundPen,    bgpen,
  844.                     BUTTON_FillPen,          bgpen,
  845.                     TAG_DONE
  846.                 ),
  847.                 TAG_DONE
  848.             ),
  849.             LAYOUT_AddChild,
  850.             NewObject
  851.             (   LAYOUT_GetClass(),         NULL,
  852.                 // layout tags
  853.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  854.                 LAYOUT_SpaceOuter,         TRUE,
  855.                 LAYOUT_DeferLayout,        TRUE,
  856.                 LAYOUT_AddChild,
  857.                 NewObject
  858.                 (   LAYOUT_GetClass(),         NULL,
  859.                     // layout tags
  860.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  861.                     LAYOUT_SpaceOuter,         TRUE,
  862.                     LAYOUT_DeferLayout,        TRUE,
  863.                     LAYOUT_AddChild,
  864.                     NewObject
  865.                     (    LAYOUT_GetClass(),    NULL,
  866.                          // layout tags
  867.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  868.                          LAYOUT_SpaceOuter,    TRUE,
  869.                          LAYOUT_DeferLayout,   TRUE,
  870.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  871.                          LAYOUT_AddImage,
  872.                          NewObject
  873.                          (   LABEL_GetClass(), NULL,
  874.                              // label tags
  875.                              LABEL_Justification, LJ_CENTRE,
  876.                              LABEL_Text,          "View:",
  877.                              TAG_END
  878.                          ),
  879.                          TAG_DONE
  880.                     ),
  881.                     LAYOUT_AddChild,
  882.                     NewObject
  883.                     (   LAYOUT_GetClass(),         NULL,
  884.                         // layout tags
  885.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  886.                         LAYOUT_SpaceOuter,         TRUE,
  887.                         LAYOUT_DeferLayout,        TRUE,
  888.                         LAYOUT_AddChild,           gadgets[GID_0_BU6] =
  889.                         NewObject
  890.                         (   NULL, "button.gadget",
  891.                             // button tags
  892.                             GA_ID,                 GID_0_BU6,
  893.                             GA_Left,               20,
  894.                             GA_Top,                20,
  895.                             GA_Width,              41,
  896.                             GA_Height,             40,
  897.                             GA_RelVerify,          TRUE,
  898.                             GA_Image,              NewObject
  899.                             (   BITMAP_GetClass(),   NULL,
  900.                                 // bitmap tags
  901.                                 BITMAP_BitMap,       bitmap[5 - 1],
  902.                                 BITMAP_Width,        35,
  903.                                 BITMAP_Height,       32,
  904.                                 TAG_DONE
  905.                             ),
  906.                             BUTTON_BackgroundPen,    bgpen,
  907.                             BUTTON_FillPen,          bgpen,
  908.                             TAG_DONE
  909.                         ),
  910.                         LAYOUT_AddChild,           gadgets[GID_0_BU7] =
  911.                         NewObject
  912.                         (   NULL, "button.gadget",
  913.                             // button tags
  914.                             GA_ID,                 GID_0_BU7,
  915.                             GA_Left,               20,
  916.                             GA_Top,                20,
  917.                             GA_Width,              41,
  918.                             GA_Height,             40,
  919.                             GA_RelVerify,          TRUE,
  920.                             GA_Image,              NewObject
  921.                             (   BITMAP_GetClass(),   NULL,
  922.                                 // bitmap tags
  923.                                 BITMAP_BitMap,       bitmap[6 - 1],
  924.                                 BITMAP_Width,        35,
  925.                                 BITMAP_Height,       32,
  926.                                 TAG_DONE
  927.                             ),
  928.                             BUTTON_BackgroundPen,    bgpen,
  929.                             BUTTON_FillPen,          bgpen,
  930.                             TAG_DONE
  931.                         ),
  932.                         TAG_DONE
  933.                     ),
  934.                     TAG_DONE
  935.                 ),
  936.                 LAYOUT_AddChild,
  937.                 NewObject
  938.                 (   LAYOUT_GetClass(),         NULL,
  939.                     // layout tags
  940.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  941.                     LAYOUT_SpaceOuter,         TRUE,
  942.                     LAYOUT_DeferLayout,        TRUE,
  943.                     LAYOUT_AddChild,
  944.                     NewObject
  945.                     (    LAYOUT_GetClass(),    NULL,
  946.                          // layout tags
  947.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  948.                          LAYOUT_SpaceOuter,    TRUE,
  949.                          LAYOUT_DeferLayout,   TRUE,
  950.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  951.                          LAYOUT_AddImage,
  952.                          NewObject
  953.                          (   LABEL_GetClass(), NULL,
  954.                              // label tags
  955.                              LABEL_Justification, LJ_CENTRE,
  956.                              LABEL_Text,          "Process:",
  957.                              TAG_END
  958.                          ),
  959.                          TAG_DONE
  960.                     ),
  961.                     LAYOUT_AddChild,
  962.                     NewObject
  963.                     (   LAYOUT_GetClass(),         NULL,
  964.                         // layout tags
  965.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  966.                         LAYOUT_SpaceOuter,         TRUE,
  967.                         LAYOUT_DeferLayout,        TRUE,
  968.                         LAYOUT_AddChild,           gadgets[GID_0_BU8] =
  969.                         NewObject
  970.                         (   NULL, "button.gadget",
  971.                             // button tags
  972.                             GA_ID,                 GID_0_BU8,
  973.                             GA_Left,               20,
  974.                             GA_Top,                20,
  975.                             GA_Width,              41,
  976.                             GA_Height,             40,
  977.                             GA_RelVerify,          TRUE,
  978.                             GA_Image,              NewObject
  979.                             (   BITMAP_GetClass(),   NULL,
  980.                                 // bitmap tags
  981.                                 BITMAP_BitMap,       bitmap[7 - 1],
  982.                                 BITMAP_Width,        35,
  983.                                 BITMAP_Height,       32,
  984.                                 TAG_DONE
  985.                             ),
  986.                             BUTTON_BackgroundPen,    bgpen,
  987.                             BUTTON_FillPen,          bgpen,
  988.                             TAG_DONE
  989.                         ),
  990.                         LAYOUT_AddChild,           gadgets[GID_0_BU9] =
  991.                         NewObject
  992.                         (   NULL, "button.gadget",
  993.                             // button tags
  994.                             GA_ID,                 GID_0_BU9,
  995.                             GA_Left,               20,
  996.                             GA_Top,                20,
  997.                             GA_Width,              41,
  998.                             GA_Height,             40,
  999.                             GA_RelVerify,          TRUE,
  1000.                             GA_Image,              NewObject
  1001.                             (   BITMAP_GetClass(),   NULL,
  1002.                                 // bitmap tags
  1003.                                 BITMAP_BitMap,       bitmap[12 - 1],
  1004.                                 BITMAP_Width,        35,
  1005.                                 BITMAP_Height,       32,
  1006.                                 TAG_DONE
  1007.                             ),
  1008.                             BUTTON_BackgroundPen,    bgpen,
  1009.                             BUTTON_FillPen,          bgpen,
  1010.                             TAG_DONE
  1011.                         ),
  1012.                         TAG_DONE
  1013.                     ),
  1014.                     TAG_DONE
  1015.                 ),
  1016.                 TAG_DONE
  1017.             ),
  1018.             LAYOUT_AddChild,
  1019.             NewObject
  1020.             (   LAYOUT_GetClass(),         NULL,
  1021.                 // layout tags
  1022.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1023.                 LAYOUT_SpaceOuter,         TRUE,
  1024.                 LAYOUT_DeferLayout,        TRUE,
  1025.                 LAYOUT_AddChild,
  1026.                 NewObject
  1027.                 (   LAYOUT_GetClass(),         NULL,
  1028.                     // layout tags
  1029.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  1030.                     LAYOUT_SpaceOuter,         TRUE,
  1031.                     LAYOUT_DeferLayout,        TRUE,
  1032.                     LAYOUT_AddChild,
  1033.                     NewObject
  1034.                     (    LAYOUT_GetClass(),       NULL,
  1035.                          // layout tags
  1036.                          LAYOUT_Orientation,      LAYOUT_ORIENT_HORIZ,
  1037.                          LAYOUT_SpaceOuter,       TRUE,
  1038.                          LAYOUT_DeferLayout,      TRUE,
  1039.                          LAYOUT_HorizAlignment,   LALIGN_CENTER,
  1040.                          LAYOUT_AddImage,
  1041.                          NewObject
  1042.                          (   LABEL_GetClass(),    NULL,
  1043.                              // label tags
  1044.                              LABEL_Justification, LJ_CENTRE,
  1045.                              LABEL_Text,          "Report:",
  1046.                              TAG_END
  1047.                          ),
  1048.                          TAG_DONE
  1049.                     ),
  1050.                     LAYOUT_AddChild,
  1051.                     NewObject
  1052.                     (   LAYOUT_GetClass(),         NULL,
  1053.                         // layout tags
  1054.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1055.                         LAYOUT_SpaceOuter,         TRUE,
  1056.                         LAYOUT_DeferLayout,        TRUE,
  1057.                         LAYOUT_AddChild,           gadgets[GID_0_BU10] =
  1058.                         NewObject
  1059.                         (   NULL, "button.gadget",
  1060.                             // button tags
  1061.                             GA_ID,                 GID_0_BU10,
  1062.                             GA_Left,               20,
  1063.                             GA_Top,                20,
  1064.                             GA_Width,              41,
  1065.                             GA_Height,             40,
  1066.                             GA_RelVerify,          TRUE,
  1067.                             GA_Image,              NewObject
  1068.                             (   BITMAP_GetClass(),   NULL,
  1069.                                 // bitmap tags
  1070.                                 BITMAP_BitMap,       bitmap[8 - 1],
  1071.                                 BITMAP_Width,        35,
  1072.                                 BITMAP_Height,       32,
  1073.                                 TAG_DONE
  1074.                             ),
  1075.                             BUTTON_BackgroundPen,    bgpen,
  1076.                             BUTTON_FillPen,          bgpen,
  1077.                             TAG_DONE
  1078.                         ),
  1079.                         LAYOUT_AddChild,           gadgets[GID_0_BU11] =
  1080.                         NewObject
  1081.                         (   NULL,                  "button.gadget",
  1082.                             // button tags
  1083.                             GA_ID,                 GID_0_BU11,
  1084.                             GA_Left,               20,
  1085.                             GA_Top,                20,
  1086.                             GA_Width,              41,
  1087.                             GA_Height,             40,
  1088.                             GA_RelVerify,          TRUE,
  1089.                             GA_Image,              NewObject
  1090.                             (   BITMAP_GetClass(),   NULL,
  1091.                                 // bitmap tags
  1092.                                 BITMAP_BitMap,       bitmap[10 - 1],
  1093.                                 BITMAP_Width,        35,
  1094.                                 BITMAP_Height,       32,
  1095.                                 TAG_DONE
  1096.                             ),
  1097.                             BUTTON_BackgroundPen,    bgpen,
  1098.                             BUTTON_FillPen,          bgpen,
  1099.                             TAG_DONE
  1100.                         ),
  1101.                         TAG_DONE
  1102.                     ),
  1103.                     TAG_DONE
  1104.                 ),
  1105.                 LAYOUT_AddChild,
  1106.                 NewObject
  1107.                 (   LAYOUT_GetClass(),         NULL,
  1108.                     // layout tags
  1109.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  1110.                     LAYOUT_SpaceOuter,         TRUE,
  1111.                     LAYOUT_DeferLayout,        TRUE,
  1112.                     LAYOUT_AddChild,
  1113.                     NewObject
  1114.                     (    LAYOUT_GetClass(),    NULL,
  1115.                          // layout tags
  1116.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  1117.                          LAYOUT_SpaceOuter,    TRUE,
  1118.                          LAYOUT_DeferLayout,   TRUE,
  1119.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  1120.                          LAYOUT_AddImage,
  1121.                          NewObject
  1122.                          (   LABEL_GetClass(), NULL,
  1123.                              // label tags
  1124.                              LABEL_Justification, LJ_CENTRE,
  1125.                              LABEL_Text,          "Conduct:",
  1126.                              TAG_END
  1127.                          ),
  1128.                          TAG_DONE
  1129.                     ),
  1130.                     LAYOUT_AddChild,
  1131.                     NewObject
  1132.                     (   LAYOUT_GetClass(),         NULL,
  1133.                         // layout tags
  1134.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1135.                         LAYOUT_SpaceOuter,         TRUE,
  1136.                         LAYOUT_DeferLayout,        TRUE,
  1137.                         LAYOUT_AddChild,           gadgets[GID_0_BU12] =
  1138.                         NewObject
  1139.                         (   NULL, "button.gadget",
  1140.                             // button tags
  1141.                             GA_ID,                 GID_0_BU12,
  1142.                             GA_Left,               20,
  1143.                             GA_Top,                20,
  1144.                             GA_Width,              41,
  1145.                             GA_Height,             40,
  1146.                             GA_RelVerify,          TRUE,
  1147.                             GA_Image,              NewObject
  1148.                             (   BITMAP_GetClass(),   NULL,
  1149.                                 // bitmap tags
  1150.                                 BITMAP_BitMap,       bitmap[3 - 1],
  1151.                                 BITMAP_Width,        35,
  1152.                                 BITMAP_Height,       32,
  1153.                                 TAG_DONE
  1154.                             ),
  1155.                             BUTTON_BackgroundPen,  bgpen,
  1156.                             BUTTON_FillPen,        bgpen,
  1157.                             TAG_DONE
  1158.                         ),
  1159.                         TAG_DONE
  1160.                     ),
  1161.                     TAG_DONE
  1162.                 ),
  1163.                 TAG_DONE
  1164.             ),
  1165.             LAYOUT_AddChild,          gadgets[GID_0_ST1] =
  1166.             NewObject
  1167.             (   STRING_GetClass(),    NULL,
  1168.                 // string tags
  1169.                 GA_ID,                GID_0_ST1,
  1170.                 GA_ReadOnly,          TRUE,
  1171.                 STRINGA_TextVal,      TITLEBARTEXT,
  1172.                 TAG_END
  1173.             ),
  1174.             CHILD_WeightedHeight,     0,
  1175.             TAG_DONE
  1176.         ),
  1177.         TAG_DONE
  1178.     )))
  1179.     {   rq("Can't create ReAction gadgets!");
  1180.     }
  1181.     unlockscreen();
  1182.     openwindow();
  1183.     loop();
  1184.     closewindow();
  1185. }
  1186.  
  1187. AGLOBAL void cleanexit(SBYTE rc)
  1188. {   BPTR  ConfigHandle;
  1189.     ULONG i;
  1190.  
  1191.     /* ASL requesters are assumed to be already closed. */
  1192.  
  1193.     /* help|about... */
  1194.     if (AboutWindowPtr)
  1195.     {   DisposeObject(AboutWinObject);
  1196.         AboutWindowPtr = AboutWinObject = NULL;
  1197.     }
  1198.  
  1199.     /* all */
  1200.     unlockscreen(); // in case the screen is locked
  1201.     closewindow();
  1202.  
  1203.     if (MenuPtr)
  1204.     {   FreeMenus(MenuPtr);
  1205.         MenuPtr = NULL;
  1206.     }
  1207.     if (VisualInfoPtr)
  1208.     {   FreeVisualInfo(VisualInfoPtr);
  1209.         VisualInfoPtr = NULL;
  1210.     }
  1211.  
  1212.     /* You can't fool around with attached lists, so we close the window
  1213.     before calling these next routines. */
  1214.  
  1215.     report_die();  // f1  clear list
  1216.     aminet_exit(); // f2  clear subdir list
  1217.     aminet_die();  // f2  clear maindir list
  1218.     acse_exit();   // f3  close timer
  1219.     manuf_die();   // f5  config data
  1220.     iff_exit();    // f6  free memory, clear lists, close iffhandles
  1221.     iff_die();     // f6  config data
  1222.     eol_die();     // f7  config data
  1223.     size_exit();   // f8  close filehandles/locks, clear full lists, free memory
  1224.     size_die();    // f8  clear empty lists
  1225.     files_exit();  // f10 clear full list, close filehandle
  1226.     files_die();   // f10 clear empty list, config data
  1227.     icon_die();    // f12 config data
  1228.  
  1229.     if (NilHandle)
  1230.     {   Close(NilHandle);
  1231.         NilHandle = NULL;
  1232.     }
  1233.     if (ram && (NilHandle = Open("NIL:", MODE_NEWFILE)))
  1234.     {   if (!SystemTags("Delete RAM:Version", SYS_Output, NilHandle, TAG_DONE))
  1235.         {   ram = FALSE;
  1236.         }
  1237.         Close(NilHandle);
  1238.         NilHandle = NULL;
  1239.     }
  1240.  
  1241.     if (EADataPtr)
  1242.     {   FreeVec(EADataPtr);
  1243.         EADataPtr = NULL;
  1244.     }
  1245.     if (FontPtr)
  1246.     {   CloseFont(FontPtr);
  1247.         FontPtr = NULL;
  1248.     }
  1249.     if (ArgsPtr)
  1250.     {   FreeArgs(ArgsPtr);
  1251.         ArgsPtr = NULL;
  1252.     }
  1253.  
  1254.     /* Dispose the images ourselves as button.gadget doesn't
  1255.      * do this for its GA_Image...
  1256.      */
  1257.  
  1258.     for (i = 0; i <= FUNCTIONS; i++)
  1259.     {   if (image[i])
  1260.         {   DisposeObject(image[i]);
  1261.             image[i] = NULL;
  1262.     }   }
  1263.          
  1264.     if (rc == EXIT_SUCCESS)
  1265.     {   if (ConfigHandle = (BPTR) Open("PROGDIR:ReportPlus.config", MODE_NEWFILE))
  1266.         {   Write(ConfigHandle, IOBuffer, 24);
  1267.             Close(ConfigHandle);
  1268.             ConfigHandle = NULL;
  1269.     }   }
  1270.  
  1271.     /* ReAction */
  1272.     if (WindowBase)
  1273.     {   CloseLibrary(WindowBase);
  1274.     }
  1275.     if (TextEditorBase)
  1276.     {   CloseLibrary(TextEditorBase);
  1277.     }
  1278.     if (StringBase)
  1279.     {   CloseLibrary(StringBase);
  1280.     }
  1281.     if (SpaceBase)
  1282.     {   CloseLibrary(SpaceBase);
  1283.     }
  1284.     if (ListBrowserBase)
  1285.     {   CloseLibrary(ListBrowserBase);
  1286.     }
  1287.     if (LayoutBase)
  1288.     {   CloseLibrary(LayoutBase);
  1289.     }
  1290.     if (LabelBase)
  1291.     {   CloseLibrary(LabelBase);
  1292.     }
  1293.     if (IntegerBase)
  1294.     {   CloseLibrary(IntegerBase);
  1295.     }
  1296.     if (FuelGaugeBase)
  1297.     {   CloseLibrary(FuelGaugeBase);
  1298.     }
  1299.     if (ChooserBase)
  1300.     {   CloseLibrary(ChooserBase);
  1301.     }
  1302.     if (CheckBoxBase)
  1303.     {   CloseLibrary(CheckBoxBase);
  1304.     }
  1305.     if (ButtonBase)
  1306.     {   CloseLibrary(ButtonBase);
  1307.     }
  1308.     if (BitMapBase)
  1309.     {   CloseLibrary(BitMapBase);
  1310.     }
  1311.  
  1312.     if (BoardsBase)
  1313.         CloseLibrary((struct Library *) BoardsBase);
  1314.     if (IconBase)
  1315.         CloseLibrary((struct Library *) IconBase);
  1316.     if (IFFParseBase)
  1317.         CloseLibrary((struct Library *) IFFParseBase);
  1318.     if (ASLBase)
  1319.         CloseLibrary((struct Library *) ASLBase);
  1320.     if (GadToolsBase)
  1321.         CloseLibrary((struct Library *) GadToolsBase);
  1322.     if (IntuitionBase)
  1323.     {   OpenWorkBench();
  1324.         CloseLibrary((struct Library *) IntuitionBase);
  1325.     }
  1326.  
  1327.     exit(rc); /* End of program. */
  1328. }
  1329.  
  1330. MODULE void clearkybd(void)
  1331. {   struct IntuiMessage* MsgPtr;
  1332.  
  1333.     while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(MainWindowPtr->UserPort))
  1334.         GT_ReplyIMsg(MsgPtr);
  1335. }
  1336.  
  1337. AGLOBAL void FreeNameNodes(struct List* ListPtr)
  1338. {   /* RKM Libraries, p. 496:
  1339.     
  1340.     "Free the entire list, including the header. The header is not
  1341.     updated as the list is freed. This function demonstrates how to
  1342.     avoid referencing freed memory when deallocating nodes." */
  1343.  
  1344.     struct NameNode *WorkNodePtr, *NextNodePtr;
  1345.     
  1346.     WorkNodePtr = (struct NameNode *) (ListPtr->lh_Head); /* first node */
  1347.     while (NextNodePtr = (struct NameNode *) (WorkNodePtr->nn_Node.ln_Succ))
  1348.     {   FreeMem(WorkNodePtr, sizeof(struct NameNode));
  1349.         WorkNodePtr = NextNodePtr;
  1350.     }
  1351.     NewList(ListPtr);
  1352. }
  1353. MODULE void FreePathnameNodes(struct List* ListPtr)
  1354. {   struct PathnameNode *WorkNodePtr, *NextNodePtr;
  1355.     
  1356.     WorkNodePtr = (struct PathnameNode *) (ListPtr->lh_Head); /* first node */
  1357.     while (NextNodePtr = (struct PathnameNode *) (WorkNodePtr->nn_Node.ln_Succ))
  1358.     {   FreeMem(WorkNodePtr, sizeof(struct PathnameNode));
  1359.         WorkNodePtr = NextNodePtr;
  1360.     }
  1361.     NewList(ListPtr);
  1362. }
  1363. AGLOBAL void helpabout(void)
  1364. {   PERSIST ABOOL       first = TRUE;
  1365.  
  1366.     if (AboutWindowPtr)
  1367.     {   return;
  1368.     }
  1369.  
  1370.     lockscreen();
  1371.     if (first)
  1372.     {   if (!(image[12] = NewObject
  1373.         (   BITMAP_GetClass(), NULL,
  1374.             BITMAP_SourceFile, imagename[12],
  1375.             BITMAP_Width,      44,
  1376.             BITMAP_Height,     38,
  1377.             BITMAP_Screen,     ScreenPtr,
  1378.         TAG_DONE)
  1379.         ))
  1380.         {   rq("Can't create ReAction image!");
  1381.         }
  1382.         GetAttr(BITMAP_BitMap, image[12], (ULONG *) &bitmap[12]);
  1383.         first = FALSE;
  1384.     }
  1385.  
  1386.     if (!(AboutWinObject = NewObject(WINDOW_GetClass(), NULL,
  1387.         // window tags
  1388.         WA_PubScreen,             ScreenPtr,
  1389.         WA_ScreenTitle,           TITLEBARTEXT,
  1390.         WA_Title,                 "About Report+",
  1391.         WA_Activate,              TRUE,
  1392.         WA_DepthGadget,           TRUE,
  1393.         WA_DragBar,               TRUE,
  1394.         WA_CloseGadget,           TRUE,
  1395.         WINDOW_Position,          WPOS_CENTERSCREEN,
  1396.         WINDOW_ParentGroup,
  1397.         NewObject
  1398.         (   LAYOUT_GetClass(),         NULL,
  1399.             // root-layout tags
  1400.             LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1401.             LAYOUT_SpaceOuter,         TRUE,
  1402.             LAYOUT_DeferLayout,        TRUE,
  1403.             LAYOUT_AddChild,
  1404.             NewObject
  1405.             (   LAYOUT_GetClass(),     NULL,
  1406.                 // layout tags
  1407.                 LAYOUT_Orientation,    LAYOUT_ORIENT_VERT,
  1408.                 LAYOUT_SpaceOuter,     TRUE,
  1409.                 LAYOUT_DeferLayout,    TRUE,
  1410.                 LAYOUT_VertAlignment,  LALIGN_CENTER,
  1411.                 LAYOUT_AddImage,
  1412.                 NewObject
  1413.                 (   BITMAP_GetClass(),   NULL,
  1414.                     // bitmap tags
  1415.                     BITMAP_BitMap,       bitmap[12],
  1416.                     BITMAP_Width,        44,
  1417.                     BITMAP_Height,       38,
  1418.                     TAG_DONE
  1419.                 ),
  1420.                 TAG_DONE
  1421.             ),
  1422.             LAYOUT_AddChild,
  1423.             NewObject
  1424.             (   LAYOUT_GetClass(), NULL,
  1425.                 // layout tags
  1426.                 LAYOUT_Orientation,    LAYOUT_ORIENT_VERT,
  1427.                 LAYOUT_SpaceOuter,     TRUE,
  1428.                 LAYOUT_DeferLayout,    TRUE,
  1429.                 LAYOUT_AddChild,
  1430.                 NewObject
  1431.                 (   LAYOUT_GetClass(), NULL,
  1432.                     // layout tags
  1433.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1434.                     LAYOUT_SpaceOuter,     FALSE,
  1435.                     LAYOUT_DeferLayout,    TRUE,
  1436.                     LAYOUT_AddImage,
  1437.                     NewObject
  1438.                     (   LABEL_GetClass(),    NULL,
  1439.                         // label tags
  1440.                         LABEL_Justification, LJ_CENTRE,
  1441.                         LABEL_Text,          TITLEBARTEXT,
  1442.                         TAG_END
  1443.                     ),
  1444.                     TAG_END
  1445.                 ),
  1446.                 LAYOUT_AddChild,
  1447.                 NewObject
  1448.                 (   LAYOUT_GetClass(),       NULL,
  1449.                     LAYOUT_Orientation,      LAYOUT_ORIENT_HORIZ,
  1450.                     LAYOUT_SpaceOuter,       FALSE,
  1451.                     LAYOUT_DeferLayout,      TRUE,
  1452.                     LAYOUT_AddImage,
  1453.                     NewObject
  1454.                     (   LABEL_GetClass(),    NULL,
  1455.                         LABEL_Justification, LJ_CENTRE,
  1456.                         LABEL_Text,          "Friday 23 August 2002",
  1457.                     TAG_END),
  1458.                 TAG_END),
  1459.                 LAYOUT_AddChild,
  1460.                 NewObject
  1461.                 (   LAYOUT_GetClass(),       NULL,
  1462.                     LAYOUT_Orientation,      LAYOUT_ORIENT_HORIZ,
  1463.                     LAYOUT_SpaceOuter,       FALSE,
  1464.                     LAYOUT_DeferLayout,      TRUE,
  1465.                     LAYOUT_AddImage,
  1466.                     NewObject
  1467.                     (   LABEL_GetClass(),    NULL,
  1468.                         // label tags
  1469.                         LABEL_Justification, LJ_CENTRE,
  1470.                         LABEL_Text,          " ",
  1471.                         TAG_END
  1472.                     ),
  1473.                     TAG_END
  1474.                 ),
  1475.                 LAYOUT_AddChild,
  1476.                 NewObject
  1477.                 (   LAYOUT_GetClass(), NULL,
  1478.                     // layout tags
  1479.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1480.                     LAYOUT_SpaceOuter,     FALSE,
  1481.                     LAYOUT_DeferLayout,    TRUE,
  1482.                     LAYOUT_AddImage,
  1483.                     NewObject
  1484.                     (   LABEL_GetClass(),    NULL,
  1485.                         // label tags
  1486.                         LABEL_Justification, LJ_CENTRE,
  1487.                         LABEL_Text,          "© 2002 Amigan Software",
  1488.                         TAG_END
  1489.                     ),
  1490.                     TAG_END
  1491.                 ),
  1492.                 LAYOUT_AddChild,
  1493.                 NewObject
  1494.                 (   LAYOUT_GetClass(), NULL,
  1495.                     // layout tags
  1496.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1497.                     LAYOUT_SpaceOuter,     FALSE,
  1498.                     LAYOUT_DeferLayout,    TRUE,
  1499.                     LAYOUT_AddImage,
  1500.                     NewObject
  1501.                     (   LABEL_GetClass(),    NULL,
  1502.                         // label tags
  1503.                         LABEL_Justification, LJ_CENTRE,
  1504.                         LABEL_Text,          "By James R. Jacobs",
  1505.                         TAG_END
  1506.                     ),
  1507.                     TAG_END
  1508.                 ),
  1509.                 TAG_DONE
  1510.             ),
  1511.             TAG_DONE
  1512.         ),
  1513.         TAG_DONE
  1514.     )))
  1515.     {   rq("Can't create ReAction objects!");
  1516.     }
  1517.     unlockscreen();
  1518.  
  1519.     if (!(AboutWindowPtr = (struct Window *) DoMethod((Object *) AboutWinObject, WM_OPEN, NULL)))
  1520.     {   rq("Can't open ReAction window!");
  1521.     }
  1522.     OffMenu(MainWindowPtr, FULLMENUNUM(MN_HELP, IN_ABOUT, NOSUB));
  1523.  
  1524.     // Obtain the window wait signal mask.
  1525.     GetAttr(WINDOW_SigMask, AboutWinObject, &aboutsignal);
  1526. }
  1527.  
  1528. AGLOBAL void closewindow(void)
  1529. {   if (MainWindowPtr)
  1530.     {   clearkybd();
  1531.  
  1532.         OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_NEW,    NOSUB));
  1533.         OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_OPEN,   NOSUB));
  1534.         OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE,   NOSUB));
  1535.         OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
  1536.  
  1537.         /* Disposing of the window object will also close the window if it is
  1538.          * already opened, and it will dispose of the layout object attached to it.
  1539.          */
  1540.         DisposeObject(WinObject[shared.function]);
  1541.         WinObject[shared.function] = NULL;
  1542.         MainWindowPtr = NULL;
  1543. }   }
  1544.  
  1545. AGLOBAL ABOOL asl(STRPTR pattern)
  1546. {   struct FileRequester* ASLRqPtr;
  1547.     ABOOL                 success;
  1548.  
  1549.     /* asldir is the directory that the ASL requester will start in. */
  1550.  
  1551.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, pattern, ASL_Window, MainWindowPtr, TAG_DONE)))
  1552.         rq("Can't create ASL request!");
  1553.     if
  1554.     (   AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, "Report+ file selector", ASL_FuncFlags, FILF_PATGAD, TAG_DONE)
  1555.      && *(ASLRqPtr->rf_File) != 0
  1556.     )
  1557.     {   strcpy(asldir, ASLRqPtr->rf_Dir);
  1558.         strcpy(aslresult, ASLRqPtr->rf_Dir);
  1559.         if (!AddPart(aslresult, ASLRqPtr->rf_File, PATHNAMEFIELD))
  1560.         {   FreeAslRequest(ASLRqPtr);
  1561.             rq("Can't add filename to pathname!");
  1562.         }
  1563.         success = TRUE;
  1564.     } else
  1565.     {   // either the user chose Cancel, or clicked OK with an empty filename
  1566.         strcpy(aslresult, "");
  1567.         success = FALSE;
  1568.     }
  1569.     // assert(ASLRqPtr);
  1570.     FreeAslRequest(ASLRqPtr);
  1571.     return(success);
  1572. }
  1573.  
  1574. AGLOBAL void loop(void)
  1575. {   SWORD oldpage = page;
  1576.     UWORD code;
  1577.     ULONG result;
  1578.  
  1579.     closer = page;
  1580.     done = FALSE;
  1581.     while (page == oldpage && !done)
  1582.     {   if (AboutWindowPtr)
  1583.         {   about_loop();
  1584.         } else
  1585.         {   if ((Wait(signal | SIGBREAKF_CTRL_C)) & SIGBREAKF_CTRL_C)
  1586.             {   done = TRUE;
  1587.                 /* should we clear the Ctrl-C signal? */
  1588.         }   }
  1589.         while ((result = DoMethod(WinObject[shared.function], WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  1590.         {   switch (result & WMHI_CLASSMASK)
  1591.             {
  1592.             case WMHI_MENUPICK:
  1593.                 handlemenus(code);
  1594.             break;
  1595.             case WMHI_CLOSEWINDOW:
  1596.                 if (page == 31)
  1597.                 {   acse_closewindow();
  1598.                 } elif (page == 0)
  1599.                 {   cleanexit(EXIT_SUCCESS);
  1600.                 } elif (page == 1)
  1601.                 {   if (shared.function == 1)
  1602.                     {   page = 11;
  1603.                     } else
  1604.                     {   assert(shared.function == 3);
  1605.                         page = 32;
  1606.                 }   }
  1607.                 else page = 0;
  1608.             break;
  1609.             case WMHI_GADGETUP:
  1610.                 if (page == 1)
  1611.                 {   sender_loop(result & WMHI_GADGETMASK);
  1612.                 } else
  1613.                 {   switch(shared.function)
  1614.                     {
  1615.                     case 0:
  1616.                         menu_loop(result & WMHI_GADGETMASK);
  1617.                     break;
  1618.                     case 1:
  1619.                         report_ra_loop(result & WMHI_GADGETMASK);
  1620.                     break;
  1621.                     case 2:
  1622.                         aminet_loop(result & WMHI_GADGETMASK);
  1623.                     break;
  1624.                     case 3:
  1625.                         acse_loop(result & WMHI_GADGETMASK);
  1626.                     break;
  1627.                     case 4:
  1628.                         autodoc_loop(result & WMHI_GADGETMASK);
  1629.                     break;
  1630.                     case 5:
  1631.                         manuf_loop(result & WMHI_GADGETMASK);
  1632.                     break;
  1633.                     case 6:
  1634.                         iff_loop(result & WMHI_GADGETMASK);
  1635.                     break;
  1636.                     case 7:
  1637.                         eol_loop(result & WMHI_GADGETMASK);
  1638.                     break;
  1639.                     case 8:
  1640.                         size_loop(result & WMHI_GADGETMASK);
  1641.                     break;
  1642.                     case 9:
  1643.                         batt_loop(result & WMHI_GADGETMASK);
  1644.                     break;
  1645.                     case 10:
  1646.                         files_loop(result & WMHI_GADGETMASK);
  1647.                     break;
  1648.                     case 11:
  1649.                         agdb_loop(result & WMHI_GADGETMASK);
  1650.                     break;
  1651.                     case 12:
  1652.                         icon_loop(result & WMHI_GADGETMASK);
  1653.                     break;
  1654.                     default:
  1655.                         assert(0);
  1656.                     break;
  1657.                 }   }
  1658.             break;
  1659.             default:
  1660.             break;
  1661. }   }   }   }
  1662.  
  1663. AGLOBAL ABOOL readin(STRPTR pathname)
  1664. {   BPTR FileHandle;
  1665.  
  1666.     if (!(FileHandle = (BPTR) Open(pathname, MODE_OLDFILE)))
  1667.         return FALSE;
  1668.     if (Read(FileHandle, IOBuffer, LONGESTFIELD) == -1)
  1669.     /* Limitation: the whole file must be < 16K */
  1670.     {   Close(FileHandle);
  1671.         return FALSE;
  1672.     }
  1673.     Close(FileHandle);
  1674.     return TRUE;
  1675. }
  1676.  
  1677. AGLOBAL void writeout(STRPTR pathname)
  1678. {   BPTR FileHandle;
  1679.  
  1680.     if (!(FileHandle = (BPTR) Open(pathname, MODE_NEWFILE)))
  1681.         rq("Can't open file for writing!");
  1682.     if (Write(FileHandle, IOBuffer, strlen(IOBuffer)) == -1)
  1683.     {   Close(FileHandle);
  1684.         rq("Can't write to file!");
  1685.     }
  1686.     Close(FileHandle);
  1687. }
  1688.  
  1689. AGLOBAL void rq(STRPTR text)
  1690. {   EasyStruct.es_TextFormat = text;
  1691.     EasyRequest(MainWindowPtr, &EasyStruct, NULL);
  1692.  
  1693.     cleanexit(EXIT_FAILURE);
  1694. }
  1695.  
  1696. AGLOBAL void readordie(STRPTR pathname)
  1697. {   BPTR LocalFileHandle;
  1698.  
  1699.     if (!(LocalFileHandle = (BPTR) Open(pathname, MODE_OLDFILE)))
  1700.         rq("Can't open file for reading!");
  1701.     if (Read(LocalFileHandle, IOBuffer, LONGESTFIELD) == -1)
  1702.     {   Close(LocalFileHandle);
  1703.         rq("Can't read file!");
  1704.     }
  1705.     Close(LocalFileHandle);
  1706. }
  1707.  
  1708. MODULE void parsewb(void)
  1709. {   struct DiskObject* DiskObject;
  1710.     STRPTR*            ToolArray;
  1711.     STRPTR             s;
  1712.  
  1713.     if ((*WBArg->wa_Name) && (DiskObject = GetDiskObject(WBArg->wa_Name)))
  1714.     {   ToolArray = (STRPTR *) DiskObject->do_ToolTypes;
  1715.  
  1716.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "PUBSCREEN"))
  1717.             strcpy(pubscreen, s);
  1718.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "NOLOGO"))
  1719.             logo = FALSE;
  1720.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "ICONTYPE"))
  1721.         {   if (MatchToolValue(s, "DISK"))
  1722.             {   icon.type = WBDISK - 1;
  1723.             } elif (MatchToolValue(s, "DRAWER"))
  1724.             {   icon.type = WBDRAWER - 1;
  1725.             } elif (MatchToolValue(s, "TOOL"))
  1726.             {   icon.type = WBTOOL - 1;
  1727.             } elif (MatchToolValue(s, "PROJECT"))
  1728.             {   icon.type = WBPROJECT - 1;
  1729.             } elif (MatchToolValue(s, "TRASHCAN"))
  1730.             {   icon.type = WBGARBAGE - 1;
  1731.             } elif (MatchToolValue(s, "DEVICE"))
  1732.             {   icon.type = WBDEVICE - 1;
  1733.             } elif (MatchToolValue(s, "KICKSTART"))
  1734.             {   icon.type = WBKICK - 1;
  1735.             } elif (MatchToolValue(s, "APPICON"))
  1736.             {   icon.type = WBAPPICON - 1;
  1737.         }   }
  1738.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "FUNCTION"))
  1739.         {   if (MatchToolValue(s, "1"))
  1740.                 page = 11;
  1741.             elif (MatchToolValue(s, "2"))
  1742.                 page = 21;
  1743.             elif (MatchToolValue(s, "3"))
  1744.                 page = 31;
  1745.             elif (MatchToolValue(s, "4"))
  1746.                 page = 41;
  1747.             elif (MatchToolValue(s, "5"))
  1748.                 page = 51;
  1749.             elif (MatchToolValue(s, "6"))
  1750.                 page = 61;
  1751.             elif (MatchToolValue(s, "7"))
  1752.                 page = 71;
  1753.             elif (MatchToolValue(s, "8"))
  1754.                 page = 81;
  1755.             elif (MatchToolValue(s, "9"))
  1756.                 page = 91;
  1757.             elif (MatchToolValue(s, "10"))
  1758.                 page = 101;
  1759.             elif (MatchToolValue(s, "11"))
  1760.             {   page = 111;
  1761.             } elif (MatchToolValue(s, "12"))
  1762.             {   page = 121;
  1763.         }   }
  1764.         FreeDiskObject(DiskObject);
  1765. }   }
  1766.  
  1767. AGLOBAL void getdate(void)
  1768. {   struct DateTime DateTime;
  1769.  
  1770.     DateTime.dat_Format  = FORMAT_DOS;
  1771.     DateTime.dat_Flags   = NULL;
  1772.     DateTime.dat_StrDay  = weekdaystring;
  1773.     DateTime.dat_StrDate = datestring;
  1774.     DateTime.dat_StrTime = timestring;
  1775.  
  1776.     DateStamp(&(DateTime.dat_Stamp));
  1777.     if (!DateToStr(&DateTime))
  1778.         rq("Can't convert date!");
  1779. }
  1780.  
  1781. AGLOBAL void AddNameToTail(struct List* ListPtr, STRPTR name)
  1782. {   /* RKM Libraries, p. 496:
  1783.     
  1784.     "Allocate a NameNode structure, copy the given name into the
  1785.     structure, then add it [to] the...list." */
  1786.  
  1787.     struct NameNode* NameNodePtr;
  1788.  
  1789.     if (!(NameNodePtr = AllocMem(sizeof(struct NameNode), MEMF_CLEAR)))
  1790.         rq("Out of memory!");
  1791.     strcpy(NameNodePtr->nn_Data, name);
  1792.     NameNodePtr->nn_Node.ln_Name = NameNodePtr->nn_Data;
  1793.     NameNodePtr->nn_Node.ln_Type = NT_USER;
  1794.     NameNodePtr->nn_Node.ln_Pri  = 0;
  1795.     AddTail((struct List *) ListPtr, (struct Node *) NameNodePtr);
  1796. }
  1797. MODULE void AddPathnameToTail(struct List* ListPtr, STRPTR name)
  1798. {   struct PathnameNode* PathnameNodePtr;
  1799.  
  1800.     if (!(PathnameNodePtr = AllocMem(sizeof(struct PathnameNode), MEMF_CLEAR)))
  1801.         rq("Out of memory!");
  1802.     strcpy(PathnameNodePtr->nn_Data, name);
  1803.     PathnameNodePtr->nn_Node.ln_Name = PathnameNodePtr->nn_Data;
  1804.     PathnameNodePtr->nn_Node.ln_Type = NT_USER;
  1805.     PathnameNodePtr->nn_Node.ln_Pri  = 0;
  1806.     AddTail((struct List *) ListPtr, (struct Node *) PathnameNodePtr);
  1807. }
  1808.  
  1809. AGLOBAL void append(STRPTR pathname)
  1810. {   BPTR FileHandle;
  1811.  
  1812.     if (!(FileHandle = (BPTR) Open(pathname, MODE_READWRITE)))
  1813.         rq("Can't open file for appending!");
  1814.     Seek(FileHandle, 0, OFFSET_END);
  1815.     if (Write(FileHandle, IOBuffer, strlen(IOBuffer)) == -1)
  1816.     {   Close(FileHandle);
  1817.         rq("Can't append to file!");
  1818.     }
  1819.     if (!Close(FileHandle))
  1820.         rq("Can't close appended file!");
  1821. }
  1822.  
  1823. MODULE void about_loop(void)
  1824. {   UWORD code;
  1825.     ULONG result;
  1826.     ABOOL localdone = FALSE;
  1827.  
  1828.     // Processes any messages for the About... window.
  1829.  
  1830.     if ((Wait(aboutsignal | SIGBREAKF_CTRL_C)) & SIGBREAKF_CTRL_C)
  1831.     {   localdone = TRUE;
  1832.         /* should we clear the Ctrl-C signal? */
  1833.     }
  1834.     while ((result = DoMethod(AboutWinObject, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  1835.     {   switch (result & WMHI_CLASSMASK)
  1836.         {
  1837.         case WMHI_MENUPICK:
  1838.             ; // handlemenus(code);
  1839.         break;
  1840.         case WMHI_CLOSEWINDOW:
  1841.             localdone = TRUE;
  1842.         break;
  1843.         default:
  1844.         break;
  1845.     }   }
  1846.  
  1847.     if (localdone)
  1848.     {   DisposeObject(AboutWinObject);
  1849.         AboutWindowPtr = AboutWinObject = NULL;
  1850.         OnMenu(MainWindowPtr, FULLMENUNUM(MN_HELP, IN_ABOUT, NOSUB));
  1851. }   }
  1852.  
  1853. AGLOBAL void parse(STRPTR terminator)
  1854. {   ABOOL done = FALSE;
  1855.     ULONG dest = 0; // index in destination string
  1856.  
  1857.     while (!done)
  1858.     {   if (IOBuffer[offset] != CR)
  1859.         {   string[dest] = IOBuffer[offset];
  1860.         }
  1861.         if (!strncmp(&IOBuffer[offset], terminator, strlen(terminator)))
  1862.         {   string[dest] = 0;
  1863.             done = TRUE;
  1864.             offset += strlen(terminator);
  1865.         } elif (offset > strlen(IOBuffer)) // we are past the end of the buffer
  1866.         {   string[0] = 0;
  1867.             done = TRUE;
  1868.         } else
  1869.         {   offset++;
  1870.             if (IOBuffer[offset] != CR)
  1871.             {   dest++;
  1872. }   }   }   }
  1873.  
  1874. AGLOBAL void parsetoend(void)
  1875. {   ABOOL done      = FALSE;
  1876.     ULONG suboffset = 0;
  1877.  
  1878.     while (!done)
  1879.     {   string[suboffset] = IOBuffer[offset];
  1880.         if (offset > strlen(IOBuffer))
  1881.         {   /* EOF */
  1882.             string[suboffset] = 0;
  1883.             done = TRUE;
  1884.         } else
  1885.         {   offset++;
  1886.             suboffset++;
  1887. }   }   }
  1888.  
  1889. AGLOBAL ABOOL saveasl(STRPTR message, STRPTR pattern)
  1890. {   struct FileRequester* ASLRqPtr;
  1891.     TEXT                  tempstring[VLONGFIELD + 1];
  1892.     ABOOL                 success;
  1893.  
  1894.     strcpy(tempstring, "Report+: ");
  1895.     strcat(tempstring, message);
  1896.  
  1897.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, "~(#?.info)", ASL_Window, MainWindowPtr, TAG_DONE)))
  1898.         rq("Can't create ASL request!");
  1899.     if
  1900.     (   AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, tempstring, ASL_FuncFlags, FILF_PATGAD | FILF_SAVE, TAG_DONE)
  1901.      && *(ASLRqPtr->rf_File) != 0
  1902.     )
  1903.     {   strcpy(asldir, ASLRqPtr->rf_Dir);
  1904.         strcpy(aslresult, ASLRqPtr->rf_Dir);
  1905.         if (!AddPart(aslresult, ASLRqPtr->rf_File, PATHNAMEFIELD))
  1906.         {   FreeAslRequest(ASLRqPtr);
  1907.             rq("Can't add filename to pathname!");
  1908.         }
  1909.         success = TRUE;
  1910.     } else
  1911.     {   strcpy(aslresult, "");
  1912.         success = FALSE;
  1913.     }
  1914.     // assert(ASLRqPtr);
  1915.     FreeAslRequest(ASLRqPtr);
  1916.     return(success);
  1917. }
  1918.  
  1919. AGLOBAL void handlemenus(UWORD code)
  1920. {   /* struct MenuItem* ItemPtr; */
  1921.  
  1922.     if (code != MENUNULL) /* while (code != MENUNULL) */
  1923.     {   /* ItemPtr = ItemAddress(MenuPtr, code); */
  1924.         switch (MENUNUM(code))
  1925.         {
  1926.         case MN_PROJECT:
  1927.             switch (ITEMNUM(code))
  1928.             {
  1929.             case IN_NEW:
  1930.                 if (shared.function == 1)
  1931.                     newreport(TRUE);
  1932.                 elif (shared.function == 2)
  1933.                     newaminet(TRUE);
  1934.                 elif (shared.function == 4)
  1935.                     newautodoc(TRUE);
  1936.                 elif (page == 111)
  1937.                     newagdb(TRUE);
  1938.             break;
  1939.             case IN_OPEN:
  1940.                 if (shared.function == 1)
  1941.                     openreport();
  1942.                 elif (shared.function == 2)
  1943.                     openaminet();
  1944.                 elif (shared.function == 4)
  1945.                     openautodoc();
  1946.                 elif (shared.function == 9)
  1947.                 {   batt_open();
  1948.                 } elif (page == 111)
  1949.                     openagdb();
  1950.             break;
  1951.             case IN_SAVE:
  1952.                 if (shared.function == 1)
  1953.                     savereport(FALSE);
  1954.                 elif (shared.function == 2)
  1955.                     saveaminet(FALSE);
  1956.                 elif (shared.function == 4)
  1957.                     saveautodoc(FALSE);
  1958.                 elif (shared.function == 9)
  1959.                 {   batt_save(FALSE);
  1960.                 } elif (page == 111)
  1961.                     saveagdb(FALSE);
  1962.             break;
  1963.             case IN_SAVEAS:
  1964.                 if (shared.function == 1)
  1965.                     savereport(TRUE);
  1966.                 elif (shared.function == 2)
  1967.                     saveaminet(TRUE);
  1968.                 elif (shared.function == 4)
  1969.                     saveautodoc(TRUE);
  1970.                 elif (shared.function == 9)
  1971.                 {   batt_save(TRUE);
  1972.                 } elif (page == 111)
  1973.                     saveagdb(TRUE);
  1974.             break;
  1975.             case IN_QUIT:
  1976.                 cleanexit(EXIT_SUCCESS);
  1977.             break;
  1978.             default:
  1979.             break;
  1980.             }
  1981.         break;
  1982.         case MN_HELP:
  1983.             switch (ITEMNUM(code))
  1984.             {
  1985.             case IN_ABOUT:
  1986.                 helpabout();
  1987.             break;
  1988.             default:
  1989.             break;
  1990.             }
  1991.         break;
  1992.         default:
  1993.         break;
  1994.         }
  1995.         /* Doing things the above way disables multi-selection,
  1996.         but prevents `endless selection'.
  1997.         code = ItemPtr->NextSelect; */
  1998. }   }
  1999.  
  2000. AGLOBAL void lockscreen(void)
  2001. {   if (pubscreen[0])
  2002.     {   if (!(ScreenPtr = LockPubScreen(pubscreen)))
  2003.         {   rq("Can't lock specified public screen!");
  2004.     }   }
  2005.     else
  2006.     {   if (!(ScreenPtr = LockPubScreen(NULL)))
  2007.         {   rq("Can't lock default public screen!");
  2008. }   }   }
  2009. AGLOBAL void unlockscreen(void)
  2010. {   if (ScreenPtr)
  2011.     {   if (pubscreen[0])
  2012.         {   UnlockPubScreen(pubscreen, ScreenPtr);
  2013.             ScreenPtr = NULL;
  2014.         } else
  2015.         {   UnlockPubScreen(NULL, ScreenPtr);
  2016.             ScreenPtr = NULL;
  2017. }   }   }
  2018.  
  2019. MODULE void eachwildcard(STRPTR subpattern, ABOOL gui)
  2020. {   struct AnchorPath* AnchorPathPtr;
  2021.     BPTR               OldDir;
  2022.     BOOL               result;
  2023.     ABOOL              done;
  2024.  
  2025.     shared.thisfile[0] = 0;
  2026.     // AnchorPathPtr must be longword aligned
  2027.     if (!(AnchorPathPtr = AllocMem(sizeof(struct AnchorPath), MEMF_ANY | MEMF_PUBLIC)))
  2028.     {   return;
  2029.     }
  2030.  
  2031.     /* We can't do the processing of the files until we have finished
  2032.     all of the Match...() calls, due to lock problems. So we build a
  2033.     list of the pathnames. */
  2034.  
  2035.     AnchorPathPtr->ap_BreakBits = NULL;
  2036.     AnchorPathPtr->ap_Flags     = NULL;
  2037.     AnchorPathPtr->ap_Strlen    = 0;
  2038.     result = MatchFirst(subpattern, AnchorPathPtr);
  2039.     if (result == 0) // 0 means success
  2040.     {   OldDir = CurrentDir(AnchorPathPtr->ap_Current->an_Lock);
  2041.         if (!NameFromLock(AnchorPathPtr->ap_Current->an_Lock, shared.thisfile, PATHNAMEFIELD))
  2042.         {   MatchEnd(AnchorPathPtr);
  2043.             return;
  2044.         }
  2045.         if (!AddPart(shared.thisfile, AnchorPathPtr->ap_Info.fib_FileName, PATHNAMEFIELD))
  2046.         {   MatchEnd(AnchorPathPtr);
  2047.             return;
  2048.         }
  2049.         CurrentDir(OldDir);
  2050.         AddPathnameToTail(&FileList, shared.thisfile);
  2051.     } elif (result != ERROR_NO_MORE_ENTRIES)
  2052.     {   MatchEnd(AnchorPathPtr);
  2053.         return;
  2054.     }
  2055.  
  2056.     done = FALSE;
  2057.     while (!done)
  2058.     {   result = MatchNext(AnchorPathPtr);
  2059.         if (result == 0)
  2060.         {   OldDir = CurrentDir(AnchorPathPtr->ap_Current->an_Lock);
  2061.             if (!NameFromLock(AnchorPathPtr->ap_Current->an_Lock, shared.thisfile, PATHNAMEFIELD))
  2062.             {   MatchEnd(AnchorPathPtr);
  2063.                 return;
  2064.             }
  2065.             if (!AddPart(shared.thisfile, AnchorPathPtr->ap_Info.fib_FileName, PATHNAMEFIELD))
  2066.             {   MatchEnd(AnchorPathPtr);
  2067.                 return;
  2068.             }
  2069.             CurrentDir(OldDir);
  2070.             AddPathnameToTail(&FileList, shared.thisfile);
  2071.         } elif (result != ERROR_NO_MORE_ENTRIES)
  2072.         {   MatchEnd(AnchorPathPtr);
  2073.             return;
  2074.         } else done = TRUE;
  2075.     }
  2076.     MatchEnd(AnchorPathPtr);
  2077.     FreeMem(AnchorPathPtr, sizeof(struct AnchorPath));
  2078. }
  2079.  
  2080. AGLOBAL void multiasl(STRPTR pattern)
  2081. {   struct FileRequester* ASLRqPtr;
  2082.     ULONG                 i;
  2083.     TEXT                  quotestring[2];
  2084.  
  2085.     quotestring[0] = QUOTE;
  2086.     quotestring[1] = 0;
  2087.  
  2088.     /* It would also be good to correctly
  2089.     handle selection of directories. */
  2090.  
  2091.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, pattern, ASL_Window, MainWindowPtr, TAG_DONE)))
  2092.         rq("Can't create ASL request!");
  2093.     if (AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, "Report+ file multiselector", ASL_FuncFlags, FILF_PATGAD | FILF_MULTISELECT, TAG_DONE) && *(ASLRqPtr->rf_File) != 0)
  2094.     {   if (ASLRqPtr->rf_NumArgs)
  2095.         {   /* rf_ArgList is an array of WBArg structures. Each entry in
  2096.             this array corresponds to one of the files the user selected
  2097.             (in alphabetical order). The user multiselected; step through
  2098.             the list of selected files. */
  2099.             strcpy(asldir, ASLRqPtr->rf_Dir);
  2100.             strcpy(shared.pathname, quotestring);
  2101.             strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2102.             if (!AddPart(shared.pathname, (ASLRqPtr->rf_ArgList)[0].wa_Name, PATHNAMEFIELD))
  2103.             {   FreeAslRequest(ASLRqPtr);
  2104.                 rq("Can't add filename to pathname!");
  2105.             }
  2106.             strcat(shared.pathname, quotestring);
  2107.             strcat(shared.pathname, " ");
  2108.             for (i = 1; i < ASLRqPtr->rf_NumArgs; i++)
  2109.             {   strcat(shared.pathname, quotestring);
  2110.                 strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2111.                 if (!AddPart(shared.pathname, (ASLRqPtr->rf_ArgList)[i].wa_Name, PATHNAMEFIELD))
  2112.                    rq("Can't add filename to pathname!");
  2113.                 strcat(shared.pathname, quotestring);
  2114.                 if (i < ASLRqPtr->rf_NumArgs - 1)
  2115.                     strcat(shared.pathname, " ");
  2116.         }   }
  2117.         else
  2118.         {   /* The user didn't multiselect; use the normal way to get the
  2119.             filename. */
  2120.  
  2121.             strcpy(asldir, ASLRqPtr->rf_Dir);
  2122.             strcpy(shared.pathname, quotestring);
  2123.             strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2124.             if (!AddPart(shared.pathname, ASLRqPtr->rf_File, PATHNAMEFIELD))
  2125.             {   FreeAslRequest(ASLRqPtr);
  2126.                 rq("Can't add filename to pathname!");
  2127.             }
  2128.             strcat(shared.pathname, quotestring);
  2129.     }   }
  2130.     else
  2131.     {   ; // the user chose Cancel
  2132.     }
  2133.     // assert(ASLRqPtr);
  2134.     FreeAslRequest(ASLRqPtr);
  2135. }
  2136.  
  2137. AGLOBAL void checkabort(ABOOL gui)
  2138. {   ULONG signals, gid, result;
  2139.     UWORD code;
  2140.  
  2141.     /* OK, we've just finished operating on that file. Now before we */
  2142.     /* start on the next one, check whether the user still wants to... */
  2143.     signals = SetSignal(0L, 0L);
  2144.     if (signals & SIGBREAKF_CTRL_C)
  2145.     {   stop = TRUE;
  2146.         SetSignal(0L, SIGBREAKF_CTRL_C); /* clear the Ctrl-C signal */
  2147.         if (gui)
  2148.         {   if (shared.function == 7)
  2149.             {   SetGadgetAttrs
  2150.                 (   eol_gadgets[GID_7_ST2], MainWindowPtr, NULL,
  2151.                     STRINGA_TextVal, "Aborted by user!",
  2152.                 TAG_DONE);
  2153.             } else
  2154.             {   // assert(shared.function == 12);
  2155.                 SetGadgetAttrs
  2156.                 (   icon_gadgets[GID_12_ST2], MainWindowPtr, NULL,
  2157.                     STRINGA_TextVal, "Aborted by user!",
  2158.                 TAG_DONE);
  2159.         }   }
  2160.         else
  2161.         {   Printf("Aborted by user!\n");
  2162.             Flush(Output());
  2163.     }   }
  2164.  
  2165.     while ((result = DoMethod(WinObject[shared.function], WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  2166.     {   switch (result & WMHI_CLASSMASK)
  2167.         {
  2168.         case WMHI_MENUPICK:
  2169.             ; /* handlemenus(code); */
  2170.         break;
  2171.         case WMHI_CLOSEWINDOW:
  2172.             done = quit = TRUE;
  2173.         break;
  2174.         case WMHI_GADGETUP:
  2175.             gid = result & WMHI_GADGETMASK;
  2176.             if
  2177.             (   (shared.function ==  7 && gid == GID_7_BU4)
  2178.              || (shared.function == 12 && gid == GID_12_BU4)
  2179.             )
  2180.             {   stop = TRUE;
  2181.             }
  2182.         break;
  2183.         default:
  2184.         break;
  2185. }   }   }
  2186.  
  2187. AGLOBAL void convert(ABOOL gui)
  2188. {   ULONG        i, j, length;
  2189.     ABOOL        letters, /* are we in letters (TRUE) or whitespace (FALSE)? */
  2190.                  quoted;  /* are we quoted (TRUE) or unquoted (FALSE)? */
  2191.     struct Node* NodePtr;
  2192.  
  2193.     /* At this point we have a list of pathnames, separated by spaces and
  2194.     NULL-terminated. If they came from ASL, they will be quoted, otherwise,
  2195.     they may not. This is the raw input; it can contain anything,
  2196.     including wildcards.
  2197.  
  2198.     shared.pathname: the actual contents of the string gadget.
  2199.     shared.thatfile: each file that we pass to eachwildcard().
  2200.     shared.thisfile: each file that we pass for conversion. */
  2201.  
  2202.     stop = letters = quoted = FALSE;
  2203.     length = strlen(shared.pathname);
  2204.     j = 0;
  2205.  
  2206.     for (i = 0; i < length; i++)
  2207.     {   if (!stop)
  2208.         {   if (shared.pathname[i] == ' ' && letters && !quoted)
  2209.             {   /* if we're unquoted and have a space */
  2210.                 shared.thatfile[j] = 0; /* then NULL-terminate the pathname */
  2211.                 eachwildcard(shared.thatfile, gui);
  2212.                 j = 0;
  2213.                 letters = FALSE;
  2214.             } elif (shared.pathname[i] == QUOTE)
  2215.             {   if (!letters && !quoted)
  2216.                 {   letters = TRUE; /* we're in letters */
  2217.                     quoted = TRUE; /* it's a quote */
  2218.                 } elif (letters && quoted)
  2219.                 {   quoted = FALSE; /* it's an unquote */
  2220.             }   }
  2221.             else
  2222.             {   shared.thatfile[j++] = shared.pathname[i];
  2223.                 letters = TRUE; /* we're in letters */
  2224.     }   }   }
  2225.     /* Now we are at the end. */
  2226.     if (!stop && letters) /* if we're in letters */
  2227.     {   shared.thatfile[j] = 0;
  2228.         /* then it is ended, quoted or not. Although we could */
  2229.         /* report an error condition if there are an odd */
  2230.         /* number of quotes (ie. a missing quote). */
  2231.         eachwildcard(shared.thatfile, gui);
  2232.     }
  2233.     // Walk the list
  2234.     for
  2235.     (   NodePtr = FileList.lh_Head;
  2236.         NodePtr->ln_Succ;
  2237.         NodePtr = NodePtr->ln_Succ
  2238.     )
  2239.     {   if (!stop)
  2240.         {   strcpy(shared.thisfile, NodePtr->ln_Name);
  2241.             if (shared.function == 7)
  2242.             {   eolconvert(gui);
  2243.             } else
  2244.             {   /* assert(shared.function == 12); */
  2245.                 iconconvert(gui);
  2246.     }   }   }
  2247.     clearpathlist(&FileList);
  2248. }
  2249.  
  2250. MODULE void menu_loop(ULONG gid)
  2251. {   switch (gid)
  2252.     {
  2253.     case GID_0_BU1:
  2254.         page = 11;  // bug report
  2255.     break;
  2256.     case GID_0_BU2:
  2257.         page = 21;  // Aminet readme
  2258.     break;
  2259.     case GID_0_BU3:
  2260.         page = 41;  // autodoc
  2261.     break;
  2262.     case GID_0_BU4:
  2263.         page = 91;  // battery RAM
  2264.     break;
  2265.     case GID_0_BU5:
  2266.         page = 111; // AGDB review
  2267.     break;
  2268.     case GID_0_BU6:
  2269.         page = 51;  // ID database
  2270.     break;
  2271.     case GID_0_BU7:
  2272.         page = 61;  // IFF FORMs
  2273.     break;
  2274.     case GID_0_BU8:
  2275.         page = 71;  // EOL/tabs
  2276.     break;
  2277.     case GID_0_BU9:
  2278.         page = 121; // icons
  2279.     break;
  2280.     case GID_0_BU10:
  2281.         page = 81;  // path size
  2282.     break;
  2283.     case GID_0_BU11:
  2284.         page = 101; // system files
  2285.     break;
  2286.     case GID_0_BU12:
  2287.         page = 31;  // ACSE
  2288.     break;
  2289.     default:
  2290.         ; // assert(0);
  2291.     break;
  2292. }   }
  2293.  
  2294. AGLOBAL ULONG Hook0Func(struct Hook *h, VOID *o, VOID *msg)
  2295. {   /* "When the hook is called, the data argument points to the 
  2296.     window object and message argument to the IntuiMessage."
  2297.  
  2298.     These IntuiMessages do not need to be replied to by the appliprog. */
  2299.  
  2300.     AUTO    UWORD code, qual;
  2301.     AUTO    ULONG class, i;
  2302.     AUTO    SWORD mousex, mousey;
  2303.     AUTO    SLONG newover;
  2304.     PERSIST ULONG over = FUNCTIONS;
  2305.  
  2306.     geta4(); // wait till here before doing anything
  2307.  
  2308.     class  = ((struct IntuiMessage *) msg)->Class;
  2309.     code   = ((struct IntuiMessage *) msg)->Code;
  2310.     qual   = ((struct IntuiMessage *) msg)->Qualifier;
  2311.     mousex = ((struct IntuiMessage *) msg)->MouseX;
  2312.     mousey = ((struct IntuiMessage *) msg)->MouseY;
  2313.  
  2314.     switch(class)
  2315.     {
  2316.     case IDCMP_RAWKEY:
  2317.         switch(code)
  2318.         {
  2319.         case SCAN_HELP:
  2320.             helpabout();
  2321.         break;
  2322.         case SCAN_ESCAPE:
  2323.             cleanexit(EXIT_SUCCESS);
  2324.         break;
  2325.         case SCAN_GRAVE:
  2326.             if (qual & IEQUALIFIER_CONTROL)
  2327.             {   decrypt();
  2328.             }
  2329.         break;
  2330.         default:
  2331.         break;
  2332.         }
  2333.     break;
  2334.     case IDCMP_INTUITICKS:
  2335.     {   newover = FUNCTIONS;
  2336.         for (i = 0; i < FUNCTIONS; i++)
  2337.         {   if
  2338.             (   mousex >= gadgets[GID_0_BU1 + i]->LeftEdge
  2339.              && mousex <= gadgets[GID_0_BU1 + i]->LeftEdge + gadgets[GID_0_BU1 + i]->Width  - 1
  2340.              && mousey >= gadgets[GID_0_BU1 + i]->TopEdge
  2341.              && mousey <= gadgets[GID_0_BU1 + i]->TopEdge  + gadgets[GID_0_BU1 + i]->Height - 1
  2342.             )
  2343.             {   newover = i;
  2344.                 break;
  2345.         }   }
  2346.         if (newover != over)
  2347.         {   over = newover;
  2348.             SetGadgetAttrs
  2349.             (   gadgets[GID_0_ST1], MainWindowPtr, NULL,
  2350.                 STRINGA_TextVal, FunctionDesc[over],
  2351.                 TAG_DONE
  2352.             );
  2353.     }   }
  2354.     break;
  2355.     default:
  2356.     break;
  2357.     }
  2358.  
  2359.     return(1);
  2360. }
  2361.  
  2362. /* This function converts register-parameter Hook calling convention into
  2363. standard C conventions. It requires a C compiler that supports
  2364. registerized parameters, such as SAS/C 5.x or greater. */
  2365.  
  2366. AGLOBAL ULONG ASM hookEntry(REG(a0) struct Hook *h, REG(a2) VOID *o, REG(a1) VOID *msg)
  2367. {   // This is the stub function that converts the register-parameters
  2368.     // to stack parameters.
  2369.  
  2370.     return ((*(ULONG (*)(struct Hook *, VOID *, VOID *))(*h->h_SubEntry))(h, o, msg));
  2371. }
  2372.  
  2373. AGLOBAL void InitHook(struct Hook* hook, ULONG (*func)(), void* data)
  2374. {   // Make sure a pointer was passed
  2375.  
  2376.     if (hook)
  2377.     {   // Fill in the Hook fields
  2378.         hook->h_Entry    = (ULONG (*)()) hookEntry;
  2379.         hook->h_SubEntry = func;
  2380.         hook->h_Data     = data;
  2381.     } else
  2382.     {   Printf("Report+: Can't initialize hook (NULL pointer)!");
  2383.         cleanexit(EXIT_FAILURE);
  2384. }   }
  2385.  
  2386. AGLOBAL void clearlist(struct List* ListPtr)
  2387. {   if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2388.     {   FreeNameNodes(ListPtr);
  2389.     }
  2390.     NewList(ListPtr); // prepare for reuse
  2391. }
  2392. MODULE void clearpathlist(struct List* ListPtr)
  2393. {   if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2394.     {   FreePathnameNodes(ListPtr);
  2395.     }
  2396.     NewList(ListPtr); // prepare for reuse
  2397. }
  2398.  
  2399. // Function to free an Exec List of ReAction ListBrowser nodes.
  2400. AGLOBAL void clearreactionlist(struct List* ListPtr)
  2401. {   /* Requirements: listbrowser class must be already open, and list
  2402.     must be detached from gadget*/
  2403.  
  2404.     if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2405.     {   FreeListBrowserList(ListPtr);
  2406.     }
  2407.     NewList(ListPtr); // prepare for reuse
  2408. }
  2409.  
  2410. AGLOBAL void openwindow(void)
  2411. {   // Opens a ReAction window.
  2412.  
  2413.     if (!(MainWindowPtr = (struct Window *) DoMethod(WinObject[shared.function], WM_OPEN, NULL)))
  2414.     {   rq("Can't open ReAction window!");        
  2415.     }
  2416.  
  2417.     // Obtain the window wait signal mask.
  2418.     GetAttr(WINDOW_SigMask, WinObject[shared.function], &signal);
  2419.  
  2420.     OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_NEW,    NOSUB));
  2421.     OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_OPEN,   NOSUB));
  2422.     OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE,   NOSUB));
  2423.     OffMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
  2424. }
  2425.  
  2426. AGLOBAL ABOOL ra_checkbreak(void)
  2427. {   ULONG result;
  2428.     UWORD code;
  2429.  
  2430.     while ((result = DoMethod(WinObject[shared.function], WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  2431.     {   switch (result & WMHI_CLASSMASK)
  2432.         {
  2433.         case IDCMP_RAWKEY:
  2434.             if (code == SCAN_ESCAPE)
  2435.                 return(1);
  2436.         break;
  2437.         case WMHI_CLOSEWINDOW:
  2438.              return(2);
  2439.         break;
  2440.         case WMHI_GADGETUP:
  2441.              if (shared.function == 8)
  2442.              {   if ((result & (WMHI_GADGETMASK)) == GID_8_BU5) // these parentheses are needed!
  2443.                  {   return(1);
  2444.              }   }
  2445.              else
  2446.              {   // assert(shared.function == 10);
  2447.                  if ((result & (WMHI_GADGETMASK)) == GID_10_BU3) // these parentheses are needed!
  2448.                  {   return(1);
  2449.              }   }
  2450.         break;
  2451.         default:
  2452.         break;
  2453.     }   }
  2454.     return(0);
  2455. }
  2456.  
  2457. AGLOBAL void sender(void)
  2458. {   struct Hook SenderHookStruct;
  2459.     STRPTR      stringptr;
  2460.  
  2461.     if (readin("S:Report.sender"))
  2462.     {   /* # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
  2463.            # Path: <email><LF>
  2464.            # ReferID: <developer><LF> */
  2465.  
  2466.         offset = 0;
  2467.         parse("# Refer: ");
  2468.         parse(",");
  2469.         strcpy(report.lastname,  string);
  2470.         parse(" (");
  2471.         strcpy(report.firstname, string);
  2472.         parse(" ,phone ");
  2473.         strcpy(report.company,   string);
  2474.         parse(")\n# Path: ");
  2475.         strcpy(report.phone,     string);
  2476.         parse("\n# ReferID: ");
  2477.         strcpy(report.email,     string);
  2478.         parse("\n");
  2479.         strcpy(report.developer, string);
  2480.     }
  2481.  
  2482.     InitHook(&SenderHookStruct, SenderHookFunc, NULL);
  2483.  
  2484.     /* Create the window object. */
  2485.     lockscreen();
  2486.  
  2487. if (!(WinObject[shared.function] =
  2488. NewObject
  2489. (
  2490.     WINDOW_GetClass(),                    NULL,
  2491.     WA_PubScreen,                         ScreenPtr,
  2492.     WA_ScreenTitle,                       "Report+",
  2493.     WA_Title,                             "Report+: Sender Details",
  2494.     WA_Activate,                          TRUE,
  2495.     WA_DepthGadget,                       TRUE,
  2496.     WA_DragBar,                           TRUE,
  2497.     WA_CloseGadget,                       TRUE,
  2498.     WA_SizeGadget,                        TRUE,
  2499.     WA_IDCMP,                             IDCMP_RAWKEY,
  2500.     WINDOW_IDCMPHook,                     &SenderHookStruct,
  2501.     WINDOW_IDCMPHookBits,                 IDCMP_RAWKEY,
  2502.     WINDOW_MenuStrip,                     MenuPtr,
  2503.     WINDOW_Position,                      WPOS_CENTERSCREEN,
  2504.     WINDOW_ParentGroup,                   sender_gadgets[GID_S_LY1] =
  2505.     NewObject
  2506.     (   LAYOUT_GetClass(),                NULL,
  2507.         LAYOUT_Orientation,               LAYOUT_ORIENT_HORIZ,
  2508.         LAYOUT_SpaceOuter,                TRUE,
  2509.         LAYOUT_DeferLayout,               TRUE,
  2510.         LAYOUT_AddChild,                  NewObject(LAYOUT_GetClass(), NULL,
  2511.             LAYOUT_Orientation,           LAYOUT_ORIENT_VERT,
  2512.             LAYOUT_SpaceOuter,            TRUE,
  2513.             LAYOUT_VertAlignment,         LALIGN_CENTER,
  2514.             LAYOUT_BevelStyle,            BVS_NONE,
  2515.             LAYOUT_AddChild,              NewObject(LAYOUT_GetClass(), NULL,
  2516.                 LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  2517.                 LAYOUT_SpaceOuter,        TRUE,
  2518.                 LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  2519.                 LAYOUT_BevelStyle,        BVS_NONE,
  2520.                 LAYOUT_AddImage,          NewObject
  2521.                 (   LABEL_GetClass(),     NULL,
  2522.                     // label
  2523.                     LABEL_Text,           "_First name:",
  2524.                     LABEL_Justification,  LJ_RIGHT,
  2525.                     TAG_END
  2526.                 ),
  2527.                 TAG_END
  2528.             ),
  2529.             CHILD_WeightedHeight,         0,
  2530.             LAYOUT_AddChild,              NewObject(LAYOUT_GetClass(), NULL,
  2531.                 // layout
  2532.                 LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  2533.                 LAYOUT_SpaceOuter,        TRUE,
  2534.                 LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  2535.                 LAYOUT_BevelStyle,        BVS_NONE,
  2536.                 LAYOUT_AddImage,          NewObject
  2537.                 (   LABEL_GetClass(),     NULL,
  2538.                     // label
  2539.                     LABEL_Text,           "_Last name:",
  2540.                     LABEL_Justification,  LJ_RIGHT,
  2541.                     TAG_END
  2542.                 ),
  2543.             TAG_END),
  2544.             CHILD_WeightedHeight,         0,
  2545.             LAYOUT_AddChild,
  2546.             NewObject
  2547.             (   LAYOUT_GetClass(),        NULL,
  2548.                 LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  2549.                 LAYOUT_SpaceOuter,        TRUE,
  2550.                 LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  2551.                 LAYOUT_BevelStyle,        BVS_NONE,
  2552.                 LAYOUT_AddImage,          NewObject
  2553.                 (   LABEL_GetClass(),     NULL,
  2554.                     // label
  2555.                     LABEL_Text,           "_Company:",
  2556.                     LABEL_Justification,  LJ_RIGHT,
  2557.                     TAG_END
  2558.                 ),
  2559.                 TAG_END
  2560.             ),
  2561.             CHILD_WeightedHeight,         0,
  2562.             LAYOUT_AddChild,              NewObject(LAYOUT_GetClass(), NULL,
  2563.                 // layout
  2564.                 LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  2565.                 LAYOUT_SpaceOuter,        TRUE,
  2566.                 LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  2567.                 LAYOUT_BevelStyle,        BVS_NONE,
  2568.                 LAYOUT_AddImage,          NewObject
  2569.                 (   LABEL_GetClass(),     NULL,
  2570.                     // label
  2571.                     LABEL_Text,           "_Phone number:",
  2572.                     LABEL_Justification,  LJ_RIGHT,
  2573.                     TAG_END
  2574.                 ),
  2575.                 TAG_END
  2576.             ),
  2577.             CHILD_WeightedHeight,         0,
  2578.             LAYOUT_AddChild,
  2579.             NewObject
  2580.             (   LAYOUT_GetClass(),        NULL,
  2581.                 LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  2582.                 LAYOUT_SpaceOuter,        TRUE,
  2583.                 LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  2584.                 LAYOUT_BevelStyle,        BVS_NONE,
  2585.                 LAYOUT_AddImage,          NewObject
  2586.                 (   LABEL_GetClass(),     NULL,
  2587.                     // label
  2588.                     LABEL_Text,           "_Developer number:",
  2589.                     LABEL_Justification,  LJ_RIGHT,
  2590.                     TAG_END
  2591.                 ),
  2592.                 TAG_END
  2593.             ),
  2594.             CHILD_WeightedHeight,         0,
  2595.             LAYOUT_AddChild,
  2596.             NewObject
  2597.             (   LAYOUT_GetClass(),        NULL,
  2598.                 LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  2599.                 LAYOUT_SpaceOuter,        TRUE,
  2600.                 LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  2601.                 LAYOUT_BevelStyle,        BVS_NONE,
  2602.                 LAYOUT_AddImage,          NewObject
  2603.                 (   LABEL_GetClass(),     NULL,
  2604.                     // label
  2605.                     LABEL_Text,           "_Email:",
  2606.                     LABEL_Justification,  LJ_RIGHT,
  2607.                 TAG_END),
  2608.             TAG_END),
  2609.             CHILD_WeightedHeight,         0,
  2610.         TAG_END),
  2611.         CHILD_WeightedWidth,              0,
  2612.         LAYOUT_AddChild,
  2613.         NewObject
  2614.         (   LAYOUT_GetClass(),        NULL,
  2615.             LAYOUT_Orientation,       LAYOUT_ORIENT_VERT,
  2616.             LAYOUT_SpaceOuter,        TRUE,
  2617.             LAYOUT_VertAlignment,     LALIGN_CENTER,
  2618.             LAYOUT_HorizAlignment,    LALIGN_CENTER,
  2619.             LAYOUT_BevelStyle,        BVS_NONE,
  2620.             LAYOUT_AddChild,          sender_gadgets[GID_S_ST1] =
  2621.             NewObject
  2622.             (   STRING_GetClass(),    NULL,
  2623.                 GA_ID,                GID_S_ST1,
  2624.                 STRINGA_TextVal,      report.firstname,
  2625.                 STRINGA_MinVisible,   20,
  2626.                 STRINGA_MaxChars,     MEDFIELD,
  2627.                 GA_TabCycle,          TRUE,
  2628.             TAG_END),
  2629.             LAYOUT_AddChild,          sender_gadgets[GID_S_ST2] =
  2630.             NewObject
  2631.             (   STRING_GetClass(),    NULL,
  2632.                 GA_ID,                GID_S_ST2,
  2633.                 STRINGA_TextVal,      report.lastname,
  2634.                 STRINGA_MinVisible,   20,
  2635.                 STRINGA_MaxChars,     MEDFIELD,
  2636.                 GA_TabCycle,          TRUE,
  2637.             TAG_END),
  2638.             LAYOUT_AddChild,          sender_gadgets[GID_S_ST3] =
  2639.             NewObject
  2640.             (   STRING_GetClass(),    NULL,
  2641.                 GA_ID,                GID_S_ST3,
  2642.                 STRINGA_TextVal,      report.company,
  2643.                 STRINGA_MinVisible,   20,
  2644.                 STRINGA_MaxChars,     MEDFIELD,
  2645.                 GA_TabCycle,          TRUE,
  2646.             TAG_END),
  2647.             LAYOUT_AddChild,          sender_gadgets[GID_S_ST4] =
  2648.             NewObject
  2649.             (   STRING_GetClass(),    NULL,
  2650.                 GA_ID,                GID_S_ST4,
  2651.                 STRINGA_TextVal,      report.phone,
  2652.                 STRINGA_MinVisible,   20,
  2653.                 STRINGA_MaxChars,     MEDFIELD,
  2654.                 GA_TabCycle,          TRUE,
  2655.             TAG_END),
  2656.             LAYOUT_AddChild,          sender_gadgets[GID_S_ST5] =
  2657.             NewObject
  2658.             (   STRING_GetClass(),    NULL,
  2659.                 GA_ID,                GID_S_ST5,
  2660.                 STRINGA_TextVal,      report.developer,
  2661.                 STRINGA_MinVisible,   20,
  2662.                 STRINGA_MaxChars,     MEDFIELD,
  2663.                 GA_TabCycle,          TRUE,
  2664.             TAG_END),
  2665.             LAYOUT_AddChild,          sender_gadgets[GID_S_ST6] =
  2666.             NewObject
  2667.             (   STRING_GetClass(),    NULL,
  2668.                 GA_ID,                GID_S_ST6,
  2669.                 STRINGA_TextVal,      report.email,
  2670.                 STRINGA_MinVisible,   20,
  2671.                 STRINGA_MaxChars,     MEDFIELD,
  2672.                 GA_TabCycle,          TRUE,
  2673.             TAG_END),
  2674.         TAG_END),
  2675.         CHILD_WeightedHeight,     0,
  2676.     TAG_END)
  2677. )))
  2678. {   rq("Can't create ReAction gadgets!");
  2679. }
  2680. unlockscreen();
  2681. openwindow();
  2682.  
  2683.     ActivateLayoutGadget(sender_gadgets[GID_S_LY1], MainWindowPtr, NULL, (Object) sender_gadgets[GID_S_ST1]);
  2684.     loop();
  2685.  
  2686.     /* write out S:Report.sender
  2687.     # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
  2688.     # Path: <email><LF>
  2689.     # ReferID: <developer><LF> */
  2690.  
  2691.     strcpy(report.refer, "# Refer: ");
  2692.     if (!(GetAttr
  2693.     (   STRINGA_TextVal, sender_gadgets[GID_S_ST2], (ULONG *) &stringptr
  2694.     )))
  2695.     {   rq("Unsupported inquiry!"); // should never happen
  2696.     }
  2697.     strcat(report.refer, stringptr);
  2698.     strcat(report.refer, ",");
  2699.     if (!(GetAttr
  2700.     (   STRINGA_TextVal, sender_gadgets[GID_S_ST1], (ULONG *) &stringptr
  2701.     )))
  2702.     {   rq("Unsupported inquiry!"); // should never happen
  2703.     }
  2704.     strcat(report.refer, stringptr);
  2705.     strcat(report.refer, " (");
  2706.     if (!(GetAttr
  2707.     (   STRINGA_TextVal, sender_gadgets[GID_S_ST3], (ULONG *) &stringptr
  2708.     )))
  2709.     {   rq("Unsupported inquiry!"); // should never happen
  2710.     }
  2711.     strcat(report.refer, stringptr);
  2712.     strcat(report.refer, " ,phone ");
  2713.     if (!(GetAttr
  2714.     (   STRINGA_TextVal, sender_gadgets[GID_S_ST4], (ULONG *) &stringptr
  2715.     )))
  2716.     {   rq("Unsupported inquiry!"); // should never happen
  2717.     }
  2718.     strcat(report.refer, stringptr);
  2719.     strcat(report.refer, ")\n");
  2720.  
  2721.     if (!(GetAttr
  2722.     (   STRINGA_TextVal, sender_gadgets[GID_S_ST6], (ULONG *) &stringptr
  2723.     )))
  2724.     {   rq("Unsupported inquiry!"); // should never happen
  2725.     }
  2726.     strcpy(report.path, "# Path: ");
  2727.     strcat(report.path, stringptr);
  2728.     strcat(report.path, "\n");
  2729.  
  2730.     if (!(GetAttr
  2731.     (   STRINGA_TextVal, sender_gadgets[GID_S_ST5], (ULONG *) &stringptr
  2732.     )))
  2733.     {   rq("Unsupported inquiry!"); // should never happen
  2734.     }
  2735.     strcpy(report.referid, "# ReferID: ");
  2736.     strcat(report.referid, stringptr);
  2737.     strcat(report.referid, "\n");
  2738.  
  2739.     strcpy(IOBuffer, report.refer);
  2740.     strcat(IOBuffer, report.path);
  2741.     strcat(IOBuffer, report.referid);
  2742.     
  2743.     writeout("S:Report.sender");
  2744.  
  2745.     closewindow();
  2746. }
  2747.  
  2748. MODULE void sender_loop(ULONG gid)
  2749. {   ;
  2750. }
  2751.  
  2752. AGLOBAL void getversion(STRPTR filename, STRPTR output)
  2753. {   ULONG i;
  2754.     TEXT  commandstring[PATHNAMEFIELD + 1];
  2755.  
  2756.     /* If you have any lock on the file or its directory, this function
  2757.     will fail (returning "?"). */
  2758.  
  2759.     if (ram)
  2760.     {   strcpy(commandstring, "RAM:Version ");
  2761.     } else
  2762.     {   strcpy(commandstring, "Version ");
  2763.     }
  2764.     strcat(commandstring, filename);
  2765.     strcat(commandstring, " >T:ReportPlus.temp");
  2766.     if (!SystemTags(commandstring, SYS_Output, Open("NIL:", MODE_NEWFILE), TAG_DONE))
  2767.     {   readordie("T:ReportPlus.temp");
  2768.         for (i = 0; i <= VLONGFIELD; i++)
  2769.         {   if (IOBuffer[i] == LF)
  2770.             {   IOBuffer[i] = 0;
  2771.                 break;
  2772.         }   }
  2773.         strcpy(output, IOBuffer);
  2774.     } else
  2775.     {   strcpy(output, "?");
  2776. }   }
  2777.  
  2778. AGLOBAL void setbar(ULONG max)
  2779. {   // Ensure we do no more than BARUPDATES updates of the progress bar.
  2780.  
  2781.     increment = max / BARUPDATES;
  2782.     if (increment == 0)
  2783.     {   increment = 1;
  2784. }   }
  2785.  
  2786. AGLOBAL ABOOL dirasl(void)
  2787. {   struct FileRequester* ASLRqPtr;
  2788.     ABOOL                 success;
  2789.  
  2790.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, "#?", ASL_Window, MainWindowPtr, ASL_ExtFlags1, FIL1F_NOFILES, TAG_DONE)))
  2791.     {   rq("Can't create ASL request!");
  2792.     }
  2793.     if (AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, "Report+ path selector", ASL_FuncFlags, FILF_PATGAD, TAG_DONE))
  2794.     {   strcpy(aslresult, ASLRqPtr->rf_Dir);
  2795.         success = TRUE;
  2796.     } else success = FALSE;
  2797.     FreeAslRequest(ASLRqPtr);
  2798.     return(success);
  2799. }
  2800.  
  2801. AGLOBAL void comma(ULONG value, STRPTR commastring)
  2802. {   ABOOL yes = FALSE;
  2803.     TEXT  valuestring[11];
  2804.  
  2805.     strcpy(commastring, " ,   ,   ,   ");
  2806.     //                    1   5   9
  2807.  
  2808.     valuestring[ 0] = '0' + (value / 1000000000);
  2809.     value %= 1000000000;
  2810.     if (valuestring[ 0] != '0')
  2811.     {   commastring[0] = valuestring[0];
  2812.         yes = TRUE;
  2813.     } else
  2814.     {   commastring[ 0] = ' ';
  2815.         commastring[ 1] = ' ';
  2816.     }
  2817.  
  2818.     valuestring[ 1] = '0' + (value /  100000000);
  2819.     value %=  100000000;
  2820.     if (yes || valuestring[1] != '0')
  2821.     {   commastring[2] = valuestring[1];
  2822.         yes = TRUE;
  2823.     } else commastring[2] = ' ';
  2824.  
  2825.     valuestring[ 2] = '0' + (value /   10000000);
  2826.     value %=   10000000;
  2827.     if (yes || valuestring[2] != '0')
  2828.     {   commastring[3] = valuestring[2];
  2829.         yes = TRUE;
  2830.     } else commastring[3] = ' ';
  2831.  
  2832.     valuestring[ 3] = '0' + (value /    1000000);
  2833.     value %=    1000000;
  2834.     if (yes || valuestring[3] != '0')
  2835.     {   commastring[4] = valuestring[3];
  2836.         yes = TRUE;
  2837.     } else
  2838.     {   commastring[4] = ' ';
  2839.         commastring[5] = ' ';
  2840.     }
  2841.  
  2842.     valuestring[ 4] = '0' + (value /     100000);
  2843.     value %=     100000;
  2844.     if (yes || valuestring[4] != '0')
  2845.     {   commastring[6] = valuestring[4];
  2846.         yes = TRUE;
  2847.     } else commastring[6] = ' ';
  2848.  
  2849.     valuestring[ 5] = '0' + (value /      10000);
  2850.     value %=      10000;
  2851.     if (yes || valuestring[5] != '0')
  2852.     {   commastring[7] = valuestring[5];
  2853.         yes = TRUE;
  2854.     } else commastring[7] = ' ';
  2855.  
  2856.     valuestring[ 6] = '0' + (value /       1000);
  2857.     value %=       1000;
  2858.     if (yes || valuestring[6] != '0')
  2859.     {   commastring[8] = valuestring[6];
  2860.         yes = TRUE;
  2861.     } else
  2862.     {   commastring[8] = ' ';
  2863.         commastring[9] = ' ';
  2864.     }
  2865.  
  2866.     valuestring[ 7] = '0' + (value /        100);
  2867.     value %=        100;
  2868.     if (yes || valuestring[7] != '0')
  2869.     {   commastring[10] = valuestring[7];
  2870.         yes = TRUE;
  2871.     } else commastring[10] = ' ';
  2872.  
  2873.     valuestring[ 8] = '0' + (value /         10);
  2874.     value %=         10;
  2875.     if (yes || valuestring[8] != '0')
  2876.     {   commastring[11] = valuestring[8];
  2877.         // yes = TRUE;
  2878.     } else commastring[11] = ' ';
  2879.  
  2880.     valuestring[ 9] = '0' +  value              ;
  2881.     commastring[12] = valuestring[9];
  2882. }
  2883.  
  2884. AGLOBAL ULONG SenderHookFunc(struct Hook *h, VOID *o, VOID *msg)
  2885. {   /* "When the hook is called, the data argument points to the 
  2886.     window object and message argument to the IntuiMessage." */
  2887.  
  2888.     UWORD code, qual;
  2889.  
  2890.     geta4(); // wait till here before doing anything
  2891.  
  2892.     code = ((struct IntuiMessage *) msg)->Code;
  2893.     qual = ((struct IntuiMessage *) msg)->Qualifier;
  2894.  
  2895.     switch(code)
  2896.     {
  2897.     case SCAN_HELP:
  2898.         helpabout();
  2899.     break;
  2900.     case SCAN_ESCAPE:
  2901.         if ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT))
  2902.         {   cleanexit(EXIT_SUCCESS);
  2903.         } else
  2904.         {   if (shared.function == 1)
  2905.             {   page = 11;
  2906.             } else
  2907.             {   assert(shared.function == 3);
  2908.                 page = 32;
  2909.         }   }
  2910.     break;
  2911.     case SCAN_F:
  2912.         ActivateLayoutGadget(sender_gadgets[GID_S_LY1], MainWindowPtr, NULL, (Object) sender_gadgets[GID_S_ST1]);
  2913.     break;
  2914.     case SCAN_L:
  2915.         ActivateLayoutGadget(sender_gadgets[GID_S_LY1], MainWindowPtr, NULL, (Object) sender_gadgets[GID_S_ST2]);
  2916.     break;
  2917.     case SCAN_C:
  2918.         ActivateLayoutGadget(sender_gadgets[GID_S_LY1], MainWindowPtr, NULL, (Object) sender_gadgets[GID_S_ST3]);
  2919.     break;
  2920.     case SCAN_P:
  2921.         ActivateLayoutGadget(sender_gadgets[GID_S_LY1], MainWindowPtr, NULL, (Object) sender_gadgets[GID_S_ST4]);
  2922.     break;
  2923.     case SCAN_D:
  2924.         ActivateLayoutGadget(sender_gadgets[GID_S_LY1], MainWindowPtr, NULL, (Object) sender_gadgets[GID_S_ST5]);
  2925.     break;
  2926.     case SCAN_E:
  2927.         ActivateLayoutGadget(sender_gadgets[GID_S_LY1], MainWindowPtr, NULL, (Object) sender_gadgets[GID_S_ST6]);
  2928.     break;
  2929.     default:
  2930.     break;
  2931.     }
  2932.  
  2933.     return(1);
  2934. }
  2935.  
  2936. AGLOBAL void addreactionnode(struct List* ListPtr, STRPTR text)
  2937. {   // This is only for single-column lists.
  2938.  
  2939.     struct Node* ListBrowserNodePtr;
  2940.  
  2941.     if (!(ListBrowserNodePtr = AllocListBrowserNode
  2942.     (   1,                   // columns,
  2943.         LBNCA_CopyText,      TRUE,
  2944.         LBNCA_Text,          text,
  2945.         TAG_END
  2946.     )))
  2947.     {   rq("Can't create ReAction listbrowser.gadget node(s)!");
  2948.     }
  2949.     AddTail(ListPtr, ListBrowserNodePtr); // AddTail() has no return code
  2950. }
  2951.